我正在尝试在我的项目中为我的页面创建一个自定义类。
这是default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : FrontPage
{
public String text;
protected void Page_Load(object sender, EventArgs e)
{
text = "";
}
}
这是FrontPage类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Summary description for FrontPage
/// </summary>
public class FrontPage
{
public DataContext db = new DataContext();
public String a;
//public void Page_Load(object sender, EventArgs e)
//{
//}
}
问题是我一直收到错误:
Make sure the class is defined in this kodefil corresponds to attribute 'inherits' and that it extends the correct base class (eg. Page or UserControl).
我做错了什么?
答案 0 :(得分:5)
添加到FrontPage
的定义:
public class FrontPage : System.Web.UI.Page
你的新课程需要从基本的'Page'课程中获得好处。