2010-07-17 72 views
1

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

这里的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).

上午什么我做错了?

回答

5

添加到您的定义FrontPage

public class FrontPage : System.Web.UI.Page 

新类需要从基本的“页面”类inhierit。

+0

我试着用谷歌搜索它没有找到答案,但它很简单 - 谢谢。 – 2010-07-17 19:27:30