views:

182

answers:

1

i see that this question has been answered: http://stackoverflow.com/questions/947134/are-there-nested-master-pages-in-asp-net-mvc

but i have a follow up questions, if i have nested master pages:

site.master section.master page

where page has a master of section.master and section.master itself has a master of site.master

can i refer to sections in both section.master and site.master?

or maybe the better questions is that i would like to the do the following and when i try to reference a section in site.master i get "can't find content section.

any suggestions?

i see examples where the page references section.master but i can't find any examples where page references site.master. For example: http://msdn.microsoft.com/en-us/library/x2b3ktt7.aspx

+1  A: 

I believe you cannot reference content of parent master page if the page has child master page set.

Instead you can chain the content from child master to parent. Like this:

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>
Dmytrii Nagirniak