0% found this document useful (0 votes)
171 views2 pages

What Is Master Page?: Content Pages

Master pages in ASP.NET allow you to create a consistent layout for web pages by defining common elements like navigation menus in a single master page file. Content pages link to a master page and fill in placeholder content areas. When a content page is requested, it merges with the master page to produce the final output combining the master page layout with the unique content from the individual page.

Uploaded by

Anushka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
171 views2 pages

What Is Master Page?: Content Pages

Master pages in ASP.NET allow you to create a consistent layout for web pages by defining common elements like navigation menus in a single master page file. Content pages link to a master page and fill in placeholder content areas. When a content page is requested, it merges with the master page to produce the final output combining the master page layout with the unique content from the individual page.

Uploaded by

Anushka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

What is master page?

ASP.NET master pages allow you to create a consistent layout for the pages in your
application. A single master page defines the look and feel and standard behavior that
you want for all of the pages (or a group of pages) in your application. You can then create
individual content pages that contain the content you want to display. When users request
the content pages, they merge with the master page to produce output that combines the
layout of the master page with the content from the content page.
Content Pages
You define the content for the master page's placeholder controls by creating individual
content pages, which are ASP.NET pages (.aspx files and, optionally, code-behind files)
that are bound to a specific master page. The binding is established in the content
page's @ Page directive by including a MasterPageFile attribute that points to the
master page to be used. For example, a content page might have the
following @ Page directive, which binds it to the Master1.master page.
<%@ Page Language="C#" MasterPageFile="~/MasterPages/Master1.master"
Title="Content Page"%>

In the content page, you create the content by adding Content controls and mapping them
to ContentPlaceHolder controls on the master page.

For example, the master page might have content placeholders called Main and Footer.
In the content page, you can create two Content controls, one that is mapped to
the ContentPlaceHolder control Main and the other mapped to
the ContentPlaceHolder control Footer, as shown in the following figure.
Replacing placeholder content
A content page might look like the following.
<% @ Page Language="C#" MasterPageFile="~/Master.master"
Title="Content Page 1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main"
Runat="Server">
Main content.
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Footer"


Runat="Server" >
Footer content.
</asp:content>

Master Pages and Themes


You cannot directly apply an ASP.NET theme to a master page. If you add a theme
attribute to the @ Master directive, the page will raise an error when it runs.
However, themes are applied to master pages under these circumstances:
 If a theme is defined in the content page. Master pages are resolved in the
context of content pages, so the content page's theme is applied to the master
page as well.

You might also like