VS.NET 2005, ASP.NET and inheriting custom classes
One of the first things that I typically do when creating a new ASP.NET application is to create a base class which all of the pages in the application will derive from. Doing this allows me to handle some common tasks, such as error handling, in a centralized location.
I just finished installing the VS.NET 2005 May CTP, and proceeded to create my first ASP.NET application using the new web application model being introduced (code-beside, rather than code-behind).
The concept of partial classes was kind of new to me, so the first thing I tried to do was this in my code file.
public partial class MyPage : PageBase
Which leads me to another issue about why a class in an ASP.NET application insists on being public. Surely, this has to be a hold-over from the ASP.NET 1.1 days. But, I digress…
This is how I accomplished this using .NET 1.1. However, using .NET 2.0, the compiler screamed at me that you couldnt change the base type when using a partial class. This does make perfect sense, as otherwise you would end up with some freaky permutation of multiple inheritance.
Anyways, I started to panic a little, thinking that perhaps this task could not be handled anymore. Surely, the ASP.NET developers wouldnt leave me hanging like this.
With a little bit of digging, I found the Inherits attribute on the Page directive.
Whew! Everything is right in the world again.
Unless your type is in an external assembly. Then you have to create a *bridge* class to sit in the middle. Ugly. Also, notice the crippled Class View. Where are your partial classes?
Funny that the Visual Studio 2005 Beta 1 IDE doesn’t include Inherits in the Intellisense.
Yes it does.
It doesn’t show in the Intellisense in my installation.
I had to put the full namespace in the Inherits=”xxx.yy.z.MyPage” to get this to work properly.
I use code-behind and when I inherit from my base page, compiler gives me the following: ASP.PageSubclass_aspx.FrameworkInitialize()’: no suitable method found to override
ASP.PageSubclass_aspx.GetTypeHashCode()’: no suitable method found to override.
Pretty frustrating. Any ideas?

Partial Success