[英]Nested MasterPages
Currently I have two MasterPages. 目前,我有两个母版页。 One is the child of the other. 一个是另一个的孩子。
Parent: 家长:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Parent.master.cs" Inherits="Parent.Parent" %>
Parent Code Behind: 后面的父代码:
namespace Project
{
public partial class Parent: System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
Child: 儿童:
<%@ Master Language="C#" MasterPageFile="~/Parent.Master" AutoEventWireup="true" CodeBehind="Child.master.cs" Inherits="Child.Master" %>
Child Code Behind: 后面的子代码:
public partial class Child : System.Web.UI.MasterPage {
I'm still getting "Parser Error Message: 'UserMasterPage' is not allowed here because it does not extend class 'System.Web.UI.MasterPage'" 我仍然收到“解析器错误消息:此处不允许使用'UserMasterPage',因为它没有扩展类'System.Web.UI.MasterPage'”
Any Help? 有帮助吗?
UPDATED with new information 更新了新信息
If your class is declared as 如果您的班级宣告为
namespace Project
{
public partial class Parent: System.Web.UI.MasterPage
{
than you should inherit from the Project namespace and then the class Parent: 比您应该从Project命名空间继承的类,然后从父类继承的类:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Parent.master.cs" Inherits="Project.Parent" %>
They must have a direct match otherwise it will not find the class for your master page. 他们必须直接匹配,否则找不到您的母版页的类。
Examples: In the scenario where you have your class inside of a namespace: 示例:在将类放在命名空间中的情况下:
namespace Project {
public partial class Parent : System.Web.UI.MasterPage {
you will use Project.Parent
您将使用Project.Parent
But if you just have: 但是,如果您只有:
public partial class Child: System.Web.UI.MasterPage {
Then you will just use Child
那你就用Child
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.