如何解决找不到 ContentPlaceHolder 错误?
尝试实现新的内容页面时遇到了“呃”时刻
,这是结构
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 属性。
我可能做错了什么?
Having a "duh" moment trying to implement a new content page
Here's the structure
Master Page
---- Nested Master Page
-------- Nested Master's Content Page
Mark up:
Master Page
<asp:ContentPlaceHolder ID="bodyContent" runat="server">
</asp:ContentPlaceHolder>
Nested Master Page
MasterPageFile="~/Views/Shared/Administrator.Master"
<asp:Content ID="Content2" CotentPlaceHolderID="bodyContent" runat="server">
</asp:Content>
Nested Master's Content Page
MasterPageFile="~/Views/Intervention/InterventionMaster.master"
<asp:Content runat="server" ID="myContent" ContentPlaceHolderID="Content2">
</asp:Content>
Receive error:
Cannot find ContentPlaceHolder 'Content2' in the master page
'/Views/Intervention/InterventionMaster.master', verify content
control's ContentPlaceHolderID attribute in the content page.
What could I be doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您没有
ID = "Content2"
的ContentPlaceHolder
。您只有具有此类 ID 的内容。使用ID="Content2"
在内容中放置另一个占位符,然后与页面内容连接。母版页
嵌套母版页
嵌套母版页
You don't have
ContentPlaceHolder
withID = "Content2"
. You have only content with such ID. Put another placeholder inside of content withID="Content2"
and then connect with the page content.Master Page
Nested Master Page
Nested Master's Content Page
一个快速的解决方案是绕过嵌套母版页
来自嵌套大师的内容页面
A dirty-quick solution would be to bypass the Nested Master Page
from the Nested Master's Content Page
使用
ID="MainContent"
Use
ID="MainContent"
Codeone 很接近,尝试使用
Codeone was close, try using