【问题标题】:how do i reference the main master in a nested master page scenario in asp.net我如何在 asp.net 的嵌套母版页场景中引用主母版
【发布时间】:2009-08-17 14:08:16
【问题描述】:

我看到这个问题已经得到回答: Are there nested master pages in ASP.NET MVC?

但如果我有嵌套母版页,我有一个后续问题:

site.master section.master 页面

其中页面有一个section.master的master,section.master本身有一个site.master的master

我可以同时参考 section.master 和 site.master 中的部分吗?

或者更好的问题是我想执行以下操作,当我尝试引用 site.master 中的一个部分时,我得到“找不到内容部分。

有什么建议吗?

我看到页面引用 section.master 的示例,但我找不到页面引用 site.master 的任何示例。例如:http://msdn.microsoft.com/en-us/library/x2b3ktt7.aspx

【问题讨论】:

    标签: asp.net-mvc master-pages


    【解决方案1】:

    如果页面设置了子母版页,我相信您无法引用父母版页的内容。

    相反,您可以将内容从子母版链接到父版。像这样:

    Top.Master:

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

    Child.Master:

    <asp:Content ContentPlaceHolderID="TopContent" ID="childContent1" runat="Server">
        <asp:ContentPlaceHolder ID="ChildContent" runat="server" />
    </asp:Content>    
    

    Page.aspx:

    <asp:Content ContentPlaceHolderID="ChildContent" ID="pageContent1" runat="Server">
        <p>This will go to the Top.Master through Child.Master</p>
    </asp:Content>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多