6.1. Consistent Page Layout with Master Pages
With most web sites, only part of the page changes when you go from one page to another. The parts that don't change usually include common regions like the header, a menu, and the footer. To create web pages with a consistent layout you need a way to define these relatively static regions in a single template file. Versions of ASP.NET prior to ASP.NET 2.0 did not have a template solution so you were forced to duplicate your page layout on every single page in the web site, or resort to weird programming tricks. Fortunately, this is no longer the case due to master pages. The biggest benefit of master pages is that they allow you to define the look and feel of all the pages in your site in a single location. This means that if you want to change the layout of your site — for instance if you want to move the menu from the left to the right — you only need to modify the master page and the pages based on this master will pick up the changes automatically.
When master pages were introduced in ASP.NET 2.0, they were quickly embraced by the developer community as the template solution for ASP.NET pages because they are very easy to use. Even better, VWD has great design-time support, as it allows you to create and view your pages at design time during development, rather than only in the browser at runtime.
To some extent, a master page looks like a normal ASPX page. It contains static HTML such as the <html>, <head>, and <body> tags, and ...
Get Beginning ASP.NET 3.5: In C# and VB now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.