- when you create the master page, you will see the content placeholder.
- it is used to allocate places on the master page and it will be changed on the content pages.
- content placeholder is a control in a master page.
- the content from the content page appears in the area made by content placeholder control.
there is two content placeholder on any master page:
- in the head the section
- in the between<form> </form>
- in the head section, we can specify meta fields such as the page description and keywords.
- these vary from page to page so if we are using the master page then this is where you would put one placeholder.
- in the form section, the actual webpage contents will paste.
- we can have multiple content placeholder on the same page.
code of head section:-
<asp:ContentPlaceHolder id="head" runat="server">
and for content(between <form></form>):-
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
- simply, it contains content which you want to display.
- page with extension .aspx are content pages like home.aspx, about.aspx, etc are content pages.
- creating individual content pages, then you define the content for the master page’s placeholder, which is ASP.NET pages that are bound to a specific master page.
- when the user requests the content pages, they merge with the master page to produce output that combined the layout of the master page with the content from the content page.
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="abc.aspx.vb" Inherits="abc" %>
- users typing the URL of the content page and request a page.
- ASP.NET fetches the page.
- when the page is fetched, the @page directive is read. the master page is read as well when the directive references a master page.
- if the pages have been first time requested, both pages are compiled.
- ASP.NET merges the content into the content placeholder s on the master page.
- the master page with the updated content is merged into the control tree of the content page.
- ASP.NET renders results to the browser.
- we have seen how one can create a single master page and base a content page on the master page.
- the nested master page is defined as the master page of the main master page. that means one master page reference to another master page is called nested master page.
- The large site might contain an overall master page that defines the look of the site. for Example of College that contains the master pages named Faculty and Student.
- just like the parent master page and child master page and both have the same extension .master. for above example: faculty.master, student.master.