+1-888-365-2779
Try Now
More in this section

Forums / Designing with Sitefinity / Nested masterpage default content

Nested masterpage default content

3 posts, 0 answered
  1. Phil BS
    Phil BS avatar
    3 posts
    Registered:
    16 Jul 2009
    21 Jul 2009
    Link to this post
    Hi all

    I have a masterpage and then a nested master page, when I edit the nestedmaster page how do I default the content from the masterpage so that I don't have to keep adding the same controls to the nested master?

    eg masterpage:
    <contentplaceholder id="topnav" />

    eg nestedmasterpag:
    <contentplaceholder id="col1" />

    I want the nestedmasterpage to default the content for topnav

    any ideas?

    cheers
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Jul 2009
    Link to this post
    Hi Phil BS,

    Below is a sample that shows how to set nested masterpage.

    1. Create a master page.

    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MyTestMaster.master.cs" Inherits="App_Master_MyTestMaster" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml"
    <head runat="server"
        <title></title
        <asp:ContentPlaceHolder id="head" runat="server"
        </asp:ContentPlaceHolder> 
    </head> 
    <body> 
        <form id="form1" runat="server"
        <div> 
        
            <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"
             
            </asp:ContentPlaceHolder> 
            <asp:ContentPlaceHolder id="ContentPlaceHolder2" runat="server"
             <asp:Label ID="lbl1" runat="server" Text="this is my master page cph 2"></asp:Label> 
            </asp:ContentPlaceHolder> 
        </div> 
        </form> 
    </body> 
    </html> 


    2. Create a nested master page.

    <%@ Master Language="C#" MasterPageFile="~/App_Master/MyTestMaster.master" AutoEventWireup="true" CodeFile="MyNestedTestMaster.master.cs" Inherits="App_Master_MyNestedTestMaster" %> 
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"
    </asp:Content> 
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"
    </asp:Content> 
     

    Note that the highlighted ContentPlaceholder with ID= "ContentPlaceHolder2" does not exist in the nested page as declaration. This makes the Label control visible in the nested page.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Duncan
    Duncan avatar
    1 posts
    Registered:
    31 Aug 2012
    31 Aug 2012
    Link to this post
    I have a similar issue, but one order of magnitude deeper...
    I have several nested masters (Global -> Section -> Sub-site -> [page]), what I want to do is set default content at the highest levels possible, but then be able to override it at the grand-child (or lower) level.

    Basically I want to be able to set default content on the Global.master page and then selectively override it at the page level, or the sub-site level.

    Can this be done?
Register for webinar
3 posts, 0 answered