【问题标题】:MasterPage.master inheriting from another class that inherits MastPageMasterPage.master 继承自另一个继承 MastPage 的类
【发布时间】:2012-11-02 03:37:26
【问题描述】:

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

编译错误:

描述:在编译服务此请求所需的资源期间发生错误。请查看以下特定错误详细信息并适当修改您的源代码。

编译器错误消息:ASPNET:确保此代码文件中定义的类与“继承”属性匹配,并且它扩展了正确的基类(例如 Page 或 UserControl)。

来源错误:

Line 8:  namespace PortfolioApplication
Line 9:  {
Line 10:     public partial class MasterPage : MasterParent
Line 11:     {
Line 12:     }

我的代码: 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 
    {

    }
}

还有: 我刚刚尝试在 MasterParent.cs 中为类头更改我的代码:

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

【问题讨论】:

    标签: asp.net inheritance master-pages


    【解决方案1】:

    partial 的每个定义都没有 MasterPage : MasterParent 修饰符。

    【讨论】:

    • 以前有过。我尝试了所有可能的情况将其删除,但仍然不行。
    • 嗯,尝试使用单个 *.cs 文件和从 MasterPage 派生的单个非部分类从头开始。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-13
    • 2023-03-27
    • 2012-04-29
    • 1970-01-01
    • 2021-11-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多