2010-07-17 71 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