MasterPage.master从继承MastPage另一个类继承 [英] MasterPage.master inheriting from another class that inherits MastPage

查看:457
本文介绍了MasterPage.master从继承MastPage另一个类继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的母版页从一个名为MasterParent类继承。在编译过程中,我得到一个错误如下:

编译错误:

说明:该请求提供服务所需资源的编译过程中出现错误。请检查下列特定错误详细信息并适当地修改源$ C ​​$ C。

编译器错误信息:ASPNET:请确保在这个code文件中定义的类继承属性匹配,并且它扩展了正确的基类(例如Page或UserControl)

源错误:

  8号线:空间PortfolioApplication
9号线:{
第10行:公共部分类母版:MasterParent
11号线:{
第12行:}

我的code:
MasterParent.cs

 使用系统;
使用System.Collections.Generic;
使用System.Linq的;
使用的System.Web;
使用System.Web.UI程序;
使用System.Web.UI.WebControls;命名空间PortfolioApplication
{
    公共抽象类MasterParent:System.Web.UI.MasterPage
    {
        保护无效的Page_Load(对象发件人,EventArgs的发送)
        {
        }        #地区的导航键。        保护无效btnPortfolio_Click(对象发件人,EventArgs的发送)
        {
            Server.Transfer的(Portfolio.aspx);
        }
        保护无效btnHome_Click(对象发件人,EventArgs的发送)
        {
            Server.Transfer的(Default.aspx的);
        }
        保护无效btnContact_Click(对象发件人,EventArgs的发送)
        {
            Server.Transfer的(Contact.aspx);
        }
        保护无效btnResume_Click(对象发件人,EventArgs的发送)
        {
            Server.Transfer的(Resume.aspx);
        }        #endregion
    }
}

MasterPage.master.cs

 使用系统;
使用System.Collections.Generic;
使用System.Linq的;
使用的System.Web;
使用System.Web.UI程序;
使用System.Web.UI.WebControls;命名空间PortfolioApplication
{
    公共类母版:MasterParent
    {    }
}

另外:
我只是想改变我的code在MasterParent.cs的类头:

 公共部分类母版:System.WEb.UI.MasterPage和我收到了同样的错误有关的传承。


解决方案

您没有部分修改器母版的所有定义: MasterParent

I have my master page inheriting from a class called MasterParent. During compilation, I get an error as following:

Compilation Error:

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

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 8:  namespace PortfolioApplication
Line 9:  {
Line 10:     public partial class MasterPage : MasterParent
Line 11:     {
Line 12:     }

My code: MasterParent.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PortfolioApplication
{
    public abstract class MasterParent : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        #region "Navigation Buttons"

        protected void btnPortfolio_Click(object sender, EventArgs e)
        {
            Server.Transfer("Portfolio.aspx");
        }
        protected void btnHome_Click(object sender, EventArgs e)
        {
            Server.Transfer("Default.aspx");
        }
        protected void btnContact_Click(object sender, EventArgs e)
        {
            Server.Transfer("Contact.aspx");
        }
        protected void btnResume_Click(object sender, EventArgs e)
        {
            Server.Transfer("Resume.aspx");
        }

        #endregion
    }
}

MasterPage.master.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PortfolioApplication
{
    public class MasterPage : MasterParent 
    {

    }
}

Also: I just tried changing my code in the MasterParent.cs for the class header:

public partial class MasterPage: System.WEb.UI.MasterPage and i am getting the same error about inheritence.

解决方案

You don't have the partial modifier on every definition of MasterPage : MasterParent.

这篇关于MasterPage.master从继承MastPage另一个类继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆