Populating the parent's parent page

I would like to have a page that uses the main page for children, fill in the placeholder for the contents of the parent, but I cannot get it to work. Whenever I try, I get the error "I can not find" CustomHead "ContentPlaceHolder on the main page" /templates/info.master ", check the contents of the ContentPlaceHolderID on the content page."

I have a main page (/templates/main.master) defined as follows:

 <% @Master Language = "#" % > < head runat = "server" >   < &  GT; Foo </&  GT;   < asp: contentplaceholder runat = "server" id = "customHead" /> </ > & ;  >   < div id = "content" >       < asp: contentplaceholder runat = "server" id = "masterContent" />   </ > > 

Then I have a child wizard (/templates/info.master), which is defined as follows:

 <%@ Master Language="C#" MasterPageFile="/templates/main.master" %> <asp:content id="homeContent" contentPlaceHolderId="masterContent" Runat="server"> <div id="info-container"> <div id="info-content"> <asp:contentplaceholder runat="server" id="infoContent"/> </div> </div> </asp:content> 

And finally, my page is defined as follows:

  <% @Page Language = "#" MasterPageFile = "/templates/info.master" % > < asp: Content ID = "head" ContentPlaceHolderID = "customHead" runat = "server" >   <! -    - >   < link rel= "stylesheet" type = "text/css" href= "foo.css" /> </:  > < asp: Content ID = "content" ContentPlaceHolderID = "childContent" runat = "server" >       </:  > > 
+4
source share
2 answers

You have not defined "customeHead" on your child’s homepage. If you want to open the content area of ​​the main root pages, you will need to open it on the main page for children.

 <%@ Master Language="C#" MasterPageFile="/templates/main.master" %> <asp:contentplaceholder runat="server" id="customHead" /> <asp:content id="homeContent" contentPlaceHolderId="masterContent" Runat="server"> <div id="info-container"> <div id="info-content"> <asp:contentplaceholder runat="server" id="infoContent"/> </div> </div> </asp:content> 
+4
source

Do you install it using this.Page.Master ?

+1
source

All Articles