Welcome to MSDN Blogs Sign in | Join | Help

Technical Weblog of Eric Charran

A Journal of My Technical Achievements and Challenges
Web Form Inheritance in .NET 2.0
Because of the changes to the compilation model and structure of aspx pages in .NET 2.0, page inheritance is becomes a tricky process.  Many of us from the .NET 1.1 days used to create BasePage classes which where inherited by other pages and provided horizontal functionality such as logging methods, error handling methods and other centralized functionality.  While the argument for page inheritance was around long before 2.0 (whether to do it or not from a true OO perspective), it is a little more challenging in .NET 2.0.  Because everything is a partial class, and the code-beside model generates the other half of the page class, there is a little complication on how inheritance would work on a web form.  See the following article and reference the "What to watch out for" section on how to provide page inheritance in ASP.NET 2.0.
http://west-wind.com/weblog/posts/3016.aspx
As the article states, you have to  do a lot of work in order to make your page inherit.  While its not straight forward, it will provide the inheritance model for your pages.  What it has prompted me to do is to consider page inheritance in general.
Posted: Tuesday, March 07, 2006 11:42 AM by echarran
Filed under:

Comments

Jeff Parker said:

No I used to do a base page class in 1.0 and 1.1, however in 2.0 I use a master page. Which basically gives me all this ability and more. So anyway my question to this would be why would you still want to create your own basepage class and not use master pages?
# March 7, 2006 12:34 PM
Anonymous comments are disabled
Page view tracker