logo
  • Jobs
  • About Me
  • Contact
  • Home
« XmlDocument vs XPathNavigator
GoogleBar for FireFox »

VS.NET 2005, ASP.NET and inheriting custom classes

Posted June 18th, 2004 by Matt Berther

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.

This entry was posted on Friday, June 18th, 2004 at 4:00 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

K. Scott Allen's Blog
June 23rd, 2004

Partial Success

Christian Romney
July 16th, 2004

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?

Christian Romney
July 16th, 2004

Funny that the Visual Studio 2005 Beta 1 IDE doesn’t include Inherits in the Intellisense.

David Starr
November 22nd, 2004

Yes it does.

Simon Harriyott
December 8th, 2004

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.

Tat
May 12th, 2005

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?

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
-->

Social
  • mattberther on twitter
Syndication
Archives
  • August 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007
  • February 2007
  • January 2007
  • December 2006
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006
  • April 2006
  • March 2006
  • February 2006
  • January 2006
  • December 2005
  • November 2005
  • October 2005
  • September 2005
  • August 2005
  • July 2005
  • June 2005
  • May 2005
  • April 2005
  • March 2005
  • February 2005
  • January 2005
  • December 2004
  • November 2004
  • October 2004
  • September 2004
  • August 2004
  • July 2004
  • June 2004
  • May 2004
  • April 2004
  • March 2004
  • February 2004
  • January 2004
  • December 2003
  • November 2003
  • October 2003
  • September 2003
  • August 2003
  • July 2003
  • June 2003
  • May 2003
  • April 2003
  • March 2003
Jobs
mattberther.com © 2003 - 2008