Tuesday, October 13, 2009

What is the use of Master Pages in ASP.NET

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.

The ContentPlaceHolder control is where the page specific content will be placed. This master page is a template that will act as the base for all subsequent pages.

A master page is an ASP.NET file with the extension .master (for example, MySite.master) with a predefined layout that can include static text, HTML elements and server controls.

The master page is identified by a special @ Master directive that replaces the @ Page directive that is used for ordinary .aspx pages. The @ Master directive can contain most of the same directives that a @ Control directive can contain. For example, the following master-page directive includes the name of a code-behind file, and assigns a class name to the master page.

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, codebehind 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.

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home