Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is one way to do this but there is a slight problem with it under certain circumstances if you are relying on any default content from a placeholder.</p> <p>In your example, you have <code>Parent1.master</code>:</p> <pre><code>&lt;div id="content"&gt; &lt;h1&gt;Lorem Ipsum, from Parent1&lt;/h1&gt; &lt;asp:ContentPlaceHolder ID="cphContent" runat="server"&gt; &lt;p&gt;I am default content from Parent1...&lt;/p&gt; &lt;/asp:ContentPlaceHolder&gt; &lt;/div&gt; </code></pre> <p>And you also have a nested <code>Parent2.master</code>, which consumes the placeholder from Parent1:</p> <pre><code>&lt;asp:Content ContentPlaceHolderID="cphContent" runat="server"&gt; &lt;h2&gt;I am some specific stuff from Parent2...&lt;/h2&gt; &lt;asp:ContentPlaceHolder ID="cphContent" runat="server"&gt; &lt;p&gt;I am default content from within Parent2!&lt;/p&gt; &lt;p&gt;We want to create another, nested CPH so that Parent3 can use it!&lt;/p&gt; &lt;p&gt;(It is seemingly OK that we can use the same ID for this CPH&lt;br /&gt; in Parent2 that we did originally in Parent1.)&lt;/p&gt; &lt;/asp:ContentPlaceHolder&gt; &lt;/asp:Content&gt; </code></pre> <p>And so now <code>Parent3.master</code> can consume the placeholder from Parent2. (And also provide another placeholder for eventual content page to consume!) Here it is:</p> <pre><code>&lt;asp:Content ContentPlaceHolderID="cphContent" runat="server"&gt; &lt;h3&gt;Hello from Parent3!&lt;/h3&gt; &lt;asp:ContentPlaceHolder ID="cphContent" runat="server"&gt; &lt;p&gt;I am more default text in yet another nested placeholder&lt;/p&gt; &lt;/asp:ContentPlaceHolder&gt; &lt;/asp:Content&gt; </code></pre> <p>Your rendered content page would look something like this:</p> <pre><code>&lt;div id="content"&gt; &lt;h1&gt;Lorem Ipsum, from Parent1&lt;/h1&gt; &lt;h2&gt;I am some specific stuff from Parent2...&lt;/h2&gt; &lt;h3&gt;Hello from Parent3!&lt;/h3&gt; &lt;p&gt;I am the plugged-in content, from the content page!&lt;/p&gt; &lt;/div&gt; </code></pre> <p>One cool thing about this approach, and why we might want to use the same names for these nested CPHs throughout the inheritance chain, is that your eventual content page could change from using any of the Parent master pages 1 through 3 without having to change anything else, so long as they expected to find something called <code>cphContent</code> to consume.</p> <p>OK, so now you have seen the fun part, but the only thing I mentioned might be a problem, is if you were trying to let any of the "default" text trickle down to any of the grand-children. By this, I mean that if your content page doesn't supply any Content for the "cphContent" placeholder, then only the default from the last master page would be used. The default from <code>Parent1.master</code> is essentially lost beyond Parent2. (Although you could certainly use the default from Parent3.) There may be a way to do this programmatically, but "out of the box" this seems to allow you to do what you asked, if you can live with this caveat.</p> <p>Best of luck!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload