asp.net – 如何解决找不到ContentPlaceHolder错误?

前端之家收集整理的这篇文章主要介绍了asp.net – 如何解决找不到ContentPlaceHolder错误?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
尝试实现新内容页面的“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>

接收错误

Cannot find ContentPlaceHolder ‘Content2’ in the master page@H_404_24@ ‘/Views/Intervention/InterventionMaster.master’,verify content@H_404_24@ control’s ContentPlaceHolderID attribute in the content page.

我该怎么做错了?

解决方法

您没有ContentPlaceHolder ID =“Content2”。你只有这样的ID的内容。在ID =“Content2”的内容中放置另一个占位符,然后连接页面内容

主页

<asp:ContentPlaceHolder ID="bodyContent" runat="server">
</asp:ContentPlaceHolder>

嵌套主页

<asp:Content ID="Content2" ContentPlaceHolderID="bodyContent" runat="server">
    <asp:ContentPlaceHolder ID="nestedContent" runat="server">
    </asp:ContentPlaceHolder>
 </asp:Content>

嵌套硕士内容

<asp:Content runat="server" ID="myContent" ContentPlaceHolderID="nestedContent">
 </asp:Content>

猜你在找的asp.Net相关文章