0% found this document useful (0 votes)
5 views

Master Pages

Uploaded by

Geetha Smiley
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Master Pages

Uploaded by

Geetha Smiley
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

Working with ASP.

NET
Master Pages

1
ASP.net Master Pages

Master pages allow you to create a consistent look and behavior


for all the pages (or group of pages) in your web application.

A master page provides a template for other pages, with shared


layout and functionality.

The master page defines placeholders for the content, which can
be overridden by content pages.

The output result is a combination of the master page and the


content page.
page.
2
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

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.

3
4
Example web site:

5
.

The idea behind these technologies is to help the developer in


creating pages faster by reducing the need to repeat the elements
that appear on every page & reducing the update time.

6
Understanding Master Pages
• A master page always has a MASTER file extension.
• A master page is always an organization tool for other Web pagges.
• it contains a special tag that identifies it as a master page to the Web
server.

7
• a master page contains ContentPlaceHolder controls that tell someone using
the master page where to add the unique information for the Web page.

• When the server sees the MasterPageFile attribute, it reads the information
found in the associated MASTER file before it reads the content from the ASPX
page. It uses the MASTER file content to build a framework for the ASPX page
and then places the unique ASPX page content within the framework.

8
Creating the Master Page
• The easiest way to add a master page to the Web site is to open Solution
Explorer. Right-click the project entry and choose Add New Item from the
context menu.
• Select Master Page option.
• Select a language for the master page you want to create.
• Click Add to add the master page to the project.
• Master pages always must have one content area as a minimum.

9
Creating a Content Page Using a Master
Page
Adding content pages doesn’t have to be slow
or time consuming. The easiest method for
creating a content page based on master page
is to:
• open the master page.
• right-click anywhere on the form in Design
view.
• choose Add Content Page from the context
menu.

The IDE creates a new content page that uses


default settings and a generic name based on
the master page.

10
Another way to create a content page using a master page is to:
• right-click the project entry in Solution Explorer.
• Choose Add New Item from the context menu.
• you’ll see the Add New Item dialog box.
• Select Web Form option.
• choose a programming language.
• type a name for the file.
• Click Select Master Page option in this dialog box.
• Click Add.

11

You might also like