自定义页面类

时间:2010-07-17 19:22:19

标签: c# asp.net

我正在尝试在我的项目中为我的页面创建一个自定义类。

这是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).

我做错了什么?

1 个答案:

答案 0 :(得分:5)

添加到FrontPage的定义:

public class FrontPage : System.Web.UI.Page

你的新课程需要从基本的'Page'课程中获得好处。