我正在尝试根据更改的MTBF值生成计量表,但是当我运行Web应用程序时,我收到错误
分析器错误 说明:解析为此请求提供服务所需的资源时发生错误。请查看以下特定的解析错误详细信息并适当修改源文件。
分析器错误消息:此处不允许使用'WebApplication1.WebForm3',因为它不扩展类'System.Web.UI.Page'。
来源错误:
第1行:
第2行:<%@ Page Language =“C#”AutoEventWireup =“true”CodeBehind =“WebForm3.aspx.cs”Inherits =“WebApplication1.WebForm3”%>
第3行:
第4行:
源文件:/WebForm3.aspx行:2
我使用过的代码如下,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class WebApplication1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
using (Testme entities = new Testme())
{
var execution = entities.TestExecutionDetails.Where(p => p.TestExecutionID == TestExecID).Select(p => p).OrderBy(p => p.StartTime).ToArray();
var failures = entities.TestExecutionDetails.Select(p => p.Result != "Pass ").Count();
var uptime = entities.TestExecutionDetails.Where(p => p.Result == "Pass ").Select(p => p);
TimeSpan elapsedDuration = new TimeSpan(0);
foreach (var p in uptime)
{
elapsedDuration += (p.EndTime.Value - p.StartTime.Value);
}
var mtbfdisplay = elapsedDuration.TotalSeconds / failures;
string str1 = @"
data = google.visualization.arrayToDataTable([";
string str2 = @"['Label', 'Value'],['MTBF'," + mtbfdisplay + @"],]);";
string str3 = @"var options = {
width: 400, height: 120, redFrom: 90, redTo: 100, yellowFrom: 75, yellowTo: 90, minorTicks: 5
};
var chart = new google.visualization.gauge(document.getelementbyid('chart-success'));
chart.draw(data, options);";
string postData = str1 + str2 + str3;
Console.WriteLine(postData);
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "test", postData, true);
}
}
}
}
aspx代码如下
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication1.WebForm3" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Label ID="Label2" runat="server" Text="1"></asp:Label>
<br />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:HiddenField ID="HiddenField1" runat="server" Value="1" />
<br />
<asp:Label ID="Label1" runat="server" Text="1"></asp:Label>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<div id="chart-success"></div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
我真的被卡住了,我甚至不知道这是否是生成图表的正确方法,请帮忙。
由于
答案 0 :(得分:2)
类WebForm3
未在任何地方声明(至少在您发布的代码中),因此很可能是这一行:
public partial class WebApplication1 : System.Web.UI.Page
应该是
public partial class WebForm3 : System.Web.UI.Page