扩展正确的基类错误

时间:2012-10-09 08:55:48

标签: c# asp.net

好的,我的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 个答案:

答案 0 :(得分: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)
        {

        }
    }
}