嵌套母版页问题

时间:2014-05-23 00:06:30

标签: html asp.net visual-studio-2012

我已经阅读了大约13个不同的页面,试图弄清楚为什么我的NestedMasterPage不起作用,其中3个在stackoverflow上,但它们似乎都没有工作。

我的NestedMasterPage看起来像这样(它最初生成时的样子):

<%@ Master Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="PTNestedMasterPage.master.cs" Inherits="MyNS.NestedMasterPages.PTNestedMasterPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
</asp:Content>

我的Site.Master很大,但它的asp:ContentPlaceHolder看起来像这样:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="MyNS.SiteMaster" %>

<asp:ContentPlaceHolder runat="server" ID="HeadContent" />
<asp:ContentPlaceHolder runat="server" ID="FeaturedContent" />
<asp:ContentPlaceHolder runat="server" ID="MainContent" />

我正在尝试将内容添加到新页面,但是当我收到错误时:

  

内容控件必须是内容页面中的顶级控件或   引用母版页的嵌套母版页。

我的页面如下:

<%@ Page Language="C#" MasterPageFile="~/NestedMasterPages/PTNestedMasterPage.master" AutoEventWireup="true" CodeBehind="M1Gloss.aspx.cs" Inherits="MyNS.PTFrame.Module_1" %>


<asp:Content ID="fContent" ContentPlaceHolderID="Content3" runat="server">

</asp:Content>

有人有什么想法吗? 谢谢马利克

1 个答案:

答案 0 :(得分:0)

行, 我的NestedMasterPage应该是这样的:

<%@ Master Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="PTNestedMasterPage.master.cs" Inherits="MyNS.NestedMasterPages.PTNestedMasterPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <asp:ContentPlaceHolder ID="HeadContent" runat="server"></asp:ContentPlaceHolder>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
    <asp:ContentPlaceHolder ID="FeaturedContent" runat="server">         </asp:ContentPlaceHolder>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ContentPlaceHolder ID="MainContent" runat="server"></asp:ContentPlaceHolder>
</asp:Content>