Master Pages
Master pages provide templates for other pages
on your web site.
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.
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.
It is very easy to implement.
Use of Master Pages
The master pages can be used to accomplish the following:
- Creating a set of controls that are common across all the web
pages and attaching them to all the web pages.
- A centralized way to change the above created set of controls
which will effectively change all the web pages.
- Dynamically changing the common UI elements on master page from
content pages based on user preferences.
Advantages:
1. 1. Centralized Updating
The common code for the functionality of your pages can be stored in the master
page's code behind, making coding and updates much easier.
2. Common Controls
How many times have you had to change menu layouts or drop down items. Placing
server controls inside the Master page means you only have to edit the control
in one location.
3. Flexibility
The Master page object model allows you to make changes to the master page from
individual content pages. This allows fine grained control over the rendering
of the final page.
4. Enhanced User Experience
Since all content pages are injected with the same master page controls, your
interface will be more consistent and will provide a more consistent look and
feel.
5. Site Management
Master pages improves site management because you're loading and having to work
on fewer modules in your IDE. Making changes to your application may not
require you to load any content pages.
6. Less Code
Content pages are much easier to work with since they really don't have to
contain any code whatsoever. A simple web app may only require code in its
masterpage.master class only.
7. Less Storage Requirements
Since most of your UI code can be put in the same masterpage, your content
pages will be considerably smaller.
Disadvantages:
1. your pages all need to have the control, it's a small bugger but
still a bugger
2. your controls shift in the control tree, at runtime they no
longer belong to the Page itself, but to the added control. For some (like me)
this might be bugging and even interfere with working code.
0 Comments