Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Content Place Holder and Master Page

    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 229
    Comment on it

    Content Place Holder:

    As the name itself signifies that the Place Holder control is used to hold the content of another controls on the web page. It does not produce any visible output (it only acts as a container for other controls on the Web page).

    We can also say that the Place Holder control is used to reserve space for controls added by code.

    Example:

    <asp:ContentPlaceHolder id="CPH1" runat="server">
    </asp:ContentPlaceHolder>
    

    Master Page:

    Master page creates a consistent look and behavior for all the pages in the web application. The master page acts as a template for other pages, with shared layout and functionality.

    The master page defines placeholders for the content, which are overridden by content pages. The output is a combination of the master page and the content page. 67 The content pages contain the content you want to display. When users request the content page, ASP.NET merges the pages to produce output that combines the layout of the master page with the content of the content page.

    Master Page Example:

    <%@ Master %>
    <html>
    <body>
    <h1> Master page</h1>
    <asp:ContentPlaceHolder id="cph" runat="server">
    </asp:ContentPlaceHolder>
    </body>
    </html>
    
    1. The master page is a normal HTML page designed as a template for other pages.
    2. The @ Master directive defines that it is a master page.
    3. The master page contains a placeholder control for individual content.
    4. The id="cph" attribute identifies the placeholder uniquely on the Master Page and hence allows many placeholders in the same master page.
    5. The master page is saved with "xxxx.master" extension. Let the name of this Master Page be master1.master.

    Content Page Example:

    <%@ Page MasterPageFile="master1.master" %>
    <asp:Content ContentPlaceHolderId="CPH1" runat="server">
      <h2>Content Page </h2>
      <form runat="server">
        <asp:TextBox id="textbox1" runat="server" />
        <asp:Button id="button1" runat="server" text="Button" />
      </form>
    </asp:Content>
    
    1. The content page is one among an individual content pages of the web.
    2. The @ Page directive defines that it is a standard content page and MasterPageFile="master1.master" defines that it uses the Master Page named as master1.
    3. The content page contains a content tag with a reference to the master page (ContentPlaceHolderId="cph").
    4. The content page is saved with "xxx.aspx" extension.

      When the user requests this page, ASP.NET merges the content page with the master page.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: