2012-10-09 54 views
0

好吧我已在Home.aspx用下面的代碼下面的錯誤擴展正確的基類錯誤

錯誤:

Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl). 

Source Error: 


Line 5: using System.Web.UI.WebControls; 
Line 6: 
Line 7: public partial class home : _BasePage 
Line 8: { 
Line 9:  protected void Page_Load(object sender, EventArgs e) 

Source File: h:\Sites\BaseSite\Home.aspx.cs Line: 7 

代碼:

public partial class home : _BasePage 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 


    } 
} 

現在我明白了,這是由於它應該繼承:System.Web.UI.Page

但是,這是我的_Basepage類:

using System; 
using System.Text; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
public class _BasePage : System.Web.UI.Page 
    { 
     /// code 

    } 

這個概念在VB中工作正常不過我究竟錯在這裏做什麼?

+1

你查看的頁面之前編譯?任何編譯錯誤? – Oded

+1

你確定你沒有任何其他錯誤?因爲可能是'_BasePage'由於其他錯誤而未編譯。 – Habib

回答

1

此代碼編譯在我的項目=>i think that you have compilation problem in your page _BasePage class

using System; 
using System.Text; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 

namespace WebApplication1 
{ 


    public class Test : System.Web.UI.Page 
    { 

    } 

    public partial class _Default : Test 
    { 
     protected void Page_Load(object sender, EventArgs e) 
     { 

     } 
    } 
} 
+0

我認爲你是正確的,好吧,我意識到我有錯誤的App_Web.sd8&23f.cs錯誤文件,只是不讓我編譯。很高興知道我的想法是健全的。 –

+0

我很樂意幫助你瑞恩 –