It's not a bug - it's the way VS.NET has to work. At runtime, the "page"
is actually running, and the components on the page are instantiated by
VS.NET, and running in the context of the page designer.

Instead of implementing your methods as abstract, why not implement them
as virtual methods and throw an exception in your default
implementation?

-John
http://www.iunknown.com


-----Original Message-----
From: DEAL John M [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, May 22, 2002 10:56 AM
To: [EMAIL PROTECTED]
Subject: [DOTNET] ASP.Net Abstract Base Page Inheritance

Hi All,

The project that I'm working on has a number of functionally distinct
ASP.Net page types that we repeatedly use.  To simplify the coding
involved with this we decided to create base pages for each of the
distinct types of ASP.Net pages.  For some of these we decided to
implement one or more abstract methods, so that programmers creating new
pages inheriting from the base page would be forced to implement page
specific methods required by the base page.  The abstract methods in
turn require that the base page also be abstract.  When we did this
everything compiled and ran fine (i.e. if we changed the code behind
page to inherit from the abstract base, the page would compile and could
be viewed in the browser).

Where we encountered a problem was when we then tried to use the VS.Net
winforms designer to add controls to the web page, it refused to enter
Design view and spit out an error stating "The file failed to load in
the Web Form designer. Please correct the following error, then load it
again: Type Abstract".  To make sure it wasn't some funky code we added
to the base class we created a simple test where we created a new class
that inherited from System.Web.UI.Page called page base and made the
class abstract (note we did not add anything to the class, making it
essentially a pass through).  We then inherited the abstract class into
a new web form, the web form would then exhibit the behavior described
above (i.e. it could be compiled and viewed, but not designed via drag
and drop).

Our best guess is that this means that while it is valid to inherit from
abstract classes, that the VS.Net IDE has some bug that won't allow it
to be visually designed. Has anyone else out there encountered a problem
like this?  and whether or not you did, do you have any explanations
that might shed some light on why this is the behavior?  or any
suggestions with how to deal with this problem?

I've tried looking around for an answer for this elsewhere, but I can't
seem to locate anything (or can't seem to phrase my search criteria
correctly :-)  so any input would be greatly appreciated. Thanks.

Have A Better One!

John Deal

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to