What's So Good About Master Pages in ASP.NET PDF Print E-mail
Written by JoeThomas   
Tuesday, 15 September 2009
ASP.NET master pages are powerful template pages containing information that is common to all pages in a site or all pages in one section of a site such as corporate logo, company information, headers, footers and navigation links. Content pages can then be created which are based on the master page(s). Master pages use the file extension ".master" which is automatically protected by the server and cannot therefore be downloaded by clients.
by JoeThomas


ASP.NET master pages are powerful template pages containing information that is common to all pages in a site or all pages in one section of a site such as corporate logo, company information, headers, footers and navigation links. Content pages can then be created which are based on the master page(s). Master pages use the file extension ".master" which is automatically protected by the server and cannot therefore be downloaded by clients.

Content pages contain a reference to the appropriate master page together with the main page content. They use the regular ASP.NET file extension: ".aspx". When the client requests a content page, the master and content pages are combined on the server and the resulting page sent back to the client.

Master pages contain locked areas, which can only be edited from the master and content areas, which can be filled with unique content each time a content page is created. You can create as many content areas as you need, though the default of one in the head area and one in the body is usually enough.

Creating a master page in Visual Studio or Visual Web Developer is dead easy. Choose Add New Item from the Website menu and click on the Master Page icon. As with regular ASP.NET pages, you can choose the coding language and specify whether code will be placed in an external file or embedded in the page itself. To create a content page, choose Add New Item from the Website menu, click on the Web Form icon and activate the option "Select Master Page". When you click the Add button, a second dialog will appear allowing you to choose a master page.

Master and content pages are great to work with from the developer's point of view: they offer a great way of controlling the structure and layout of all the pages in a site. In addition, when working on content pages in Visual Studio or Visual Web Developer, the master page elements are displayed in preview mode, so the developer can always see what the final, composite page will look like to the end user. Naturally, however, the master page items cannot be edited from the content page.

Anyone familiar with Dreamweaver may be tempted to make a comparison between Dreamweaver templates and ASP.NET master pages. However, ASP.NET master pages are much more powerful. In Dreamweaver, all of the template markup has to be copied into each page based on a template. If the template is altered, each page based on the template has to be updated and then uploaded to the server. With ASP.NET master pages, the master page elements are automatically combined with the content page element at runtime by the ASP.NET engine. So when a master page is altered, there is no need to manually update the content pages.

About the Author:


From the Webmaster:

"Having the opportunity to share my hobbies and interests with so many people around the world gives me great satisfaction. As a bonus, I blog and produce websites about topics that interest me and receive ad revenue from the websites and Blogs."


You can live like this too. Get your domain name and set up a blog on your favorite place or topic. No come-ons. No "Get-Rich-Quick" promises. The results are worth the time and effort needed to build a REAL business.You can start your first or your fiftieth Blog or website to build long- term, ever-growing profits that can take you where you want to go.


For less than $10 dollars a year for a domain name and $3.95 a month for basic blog hosting you can start to earn from your hobby or interest

Click here to sign up for a domain name and Blog hosting to begin.

Or Click here to learn more about starting a blog or website for profit


 
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 192 bytes) in /home/midicity/public_html/content/components/com_sef/cache/shCacheContent.php on line 4517