Webform不允许,因为它不扩展Class

时间:2017-05-03 20:33:48

标签: c# asp.net

我有一个非常简单(当前)的1页aspx网站。它无法使用我以前从未见过的消息进行编译。所有其他示例似乎都是指母版页,我没有。

“解析器错误消息:此处不允许'Options.WebForm1',因为它不扩展类'System.Web.UI.Page'。 来源错误: 第1行:<%@ Page Language =“C#”AutoEventWireup =“true”CodeBehind =“Default.aspx.cs”Inherits =“Options.WebForm1”%> 第2行:
第3行:

这是Default.aspx的顶部

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"     
Inherits="Options.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

对于Default.aspx.cs

namespace Options
{
    public partial class _Default : Page
    {

1 个答案:

答案 0 :(得分:2)

什么是选项.WebForm1在&lt;%@ Page Language =&#34; C#&#34; AutoEventWireup =&#34;真&#34;代码隐藏=&#34; Default.aspx.cs&#34;继承=&#34; Options.WebForm1&#34; %GT;

如果您使用命名空间

,它应该如下所示
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Options._Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:GridView runat="server" ID="grdTest"></asp:GridView>
        </div>
        <asp:TextBox runat="server" Id ="callfmptxt"/>  
    </form>
</body>
</html>

代码背后 -

using System;
using System.Web.UI;
namespace Options
{
    public partial class _Default : Page
    {
        private double callfmp = 0;
        public double BlackScholes(string CallPutFlag, double S, double X, double T, double r, double v) { return 0.0;}
        protected void allfmptxt_TextChanged(object sender, EventArgs e) { }
    }
}
相关问题