Sunday, August 28, 2011

How to add master page in ASP.net web form


Master pages give your site a steady look and feel

Master pages contain both HTML and a code part

They create a common template that can be used on many pages

Updating the master page automatically updates all pages using it

A master page has 2 parts

1. Content that appears on each page that inherits the master page
2. Regions that can be customized by the pages inheriting the master page

Master pages can contain HTML, Web controls and server side source code

* Open Visual Studio
* Add a new item
* Select Master Page
Master pages end with .Master

BY default visual studio names the master page masterPage.master

A Master page need to specify both the parts common to all pages and the parts that are customizable

Items you add to the master page appear on all pages that inherit it

Use contentPlaceHolder controls to specify a region that can be customized

Add a table to the Master page
It adds on ContentPlaceHolder by default

If you place controls outside the content placeholders they will be displayed on all pages

You can have multiple contentPlaceHolder controls

Each contentPlaceHolder control can be used to customize the ASP.Net page that inherits the master page

* Add a new item
* Select Web form
* Check Select Master Page checkbox

All masterpages in your site will appear

No comments:

Post a Comment