Essential ASP.NET 2.0 by Fritz Onion

Using a common base class for a master page makes the most sense if you plan on having multiple master pages that could be affiliated with a page and then adding the ability to change the affiliation at runtime. To change the master page affiliation, you can use the MasterPageFile property, which is exposed as a public property on the Page class and can be modified in the code for any page.

Override the virtual OnLoad method. Each of these techniques essentially accomplishes the same task, and in the end it doesn't matter which way you do it. The virtual method override is going to be marginally faster than the explicitly or implicitly wired 31 32 delegate approaches, but in general the difference in overhead will typically be dwarfed by other activities in your page (like data access). If you are using Visual Studio 2005, the technique it uses for you by default is the implicit delegate wireup based on the method's name.

Download PDF sample

Rated 4.40 of 5 – based on 28 votes