【发布时间】:2012-03-02 05:58:05
【问题描述】:
尝试实现一个新的内容页面时有一个“duh”时刻
这是结构
Master Page
---- Nested Master Page
-------- Nested Master's Content Page
标记:
母版页
<asp:ContentPlaceHolder ID="bodyContent" runat="server">
</asp:ContentPlaceHolder>
嵌套母版页
MasterPageFile="~/Views/Shared/Administrator.Master"
<asp:Content ID="Content2" CotentPlaceHolderID="bodyContent" runat="server">
</asp:Content>
嵌套大师的内容页面
MasterPageFile="~/Views/Intervention/InterventionMaster.master"
<asp:Content runat="server" ID="myContent" ContentPlaceHolderID="Content2">
</asp:Content>
接收错误:
在母版页中找不到 ContentPlaceHolder 'Content2' '/Views/Intervention/InterventionMaster.master',验证内容 内容页中控件的 ContentPlaceHolderID 属性。
我做错了什么?
【问题讨论】:
-
您的内容页是否可能指的是最外层的母版页而不是嵌套的母版页?
-
首先,您正在嵌套母版页。这给你带来了什么?很可能您在 aspx 页面的顶部有错误的主定义。你能告诉我们嵌套内容页面的 MasterPageFile 指令吗?
-
@n8wrl - 不知道怎么做,因为我在内容页面中有这个:MasterPageFile="~/Views/Intervention/InterventionMaster.master
-
@subt13:根据文档,嵌套内容页面需要引用嵌套母版而不是父级。我会先看看这个作为调试的第一点。
-
@JoelEtherton - 嵌套母版页使我免于编写大量冗余标记
标签: asp.net webforms master-pages