C# 嵌套母版页
目前我有两个母版页。一个是另一个的孩子 家长:C# 嵌套母版页,c#,asp.net,master-pages,C#,Asp.net,Master Pages,目前我有两个母版页。一个是另一个的孩子 家长: <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Parent.master.cs" Inherits="Parent.Parent" %> 儿童: <%@ Master Language="C#" MasterPageFile="~/Parent.Master" AutoEventWireup="true" CodeBehind="Child.master.
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Parent.master.cs" Inherits="Parent.Parent" %>
儿童:
<%@ Master Language="C#" MasterPageFile="~/Parent.Master" AutoEventWireup="true" CodeBehind="Child.master.cs" Inherits="Child.Master" %>
我还是很紧张
“解析器错误消息:此处不允许使用UserMasterPage,因为它不扩展类'System.Web.UI.MasterPage'”
有什么帮助吗?更新了新信息 如果您的类被声明为
namespace Project
{
public partial class Parent: System.Web.UI.MasterPage
{
然后从项目命名空间继承,然后从类父级继承:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Parent.master.cs" Inherits="Project.Parent" %>
您将使用Project.Parent
但如果你有:
public partial class Child: System.Web.UI.MasterPage {
然后您将只使用
Child
@KevinFischer,而不是Inherits=“Child.Master”
,或者这是不正确的?如果您有Inherits=“Child”
,那么您可以更新问题中的代码吗?哦,您是对的!让我检查一下workedI是否添加了更多的解释,这样您就可以了解为什么对父页面使用:)了,因为您的类位于名称空间中,您必须首先调用名称空间。您的命名空间是Project,类是Parent。因此,如果您Inherits=“Project.Parent”
,则不应出现该错误。这同样适用于您的子页面。如果它有名称空间,你必须包含它。让我们来看看。更改/回答有用吗?遗憾的是,没有。我用我目前遇到的问题回答了你的回答
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Parent.master.cs" Inherits="Project.Parent" %>
namespace Project {
public partial class Parent : System.Web.UI.MasterPage {
public partial class Child: System.Web.UI.MasterPage {