Can't derive from abstract web page

  • Thread starter Thread starter Henke
  • Start date Start date
H

Henke

Hi!

I have a abstract base class that derives from System.Web.UI.Page. In this
class I have some abstract methods.
My other web pages should derive from this class and implement the abstract
methods. When I try to display the derived web page in the designer I get an
error:
" The file could not be loaded into the Web Forms designer. Please correct
the following error and then try loading it again:

Type Abstract

Make sure...."

It seams that a web page can not derive from a abstract class, is it really
so?

Thanks in advance.

/Henke
 
It seams that a web page can not derive from a abstract class, is it
really

Yes and no :-)

It can descend from the abstract class, but the designer always creates an
instance of the parent class (which is abstract). You can design your pages
using HTML but not the WYSIWYG designer.

Instead of making your page abstract you could implement the abstract
methods and just throw an exception. Although unimplemented "abstract"
methods will then surface at runtime rather than compile time, so you may
not want to do this. Personally, I'd stick to the HTML editor anyway (and
do).


--
Pete
====
Audio compression components, DIB graphics controls, FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com
 
Ok, that answers my question anyway, but I think it's quite odd though...

Well, it makes sense if you think about it. To represent a page the page
the designer must start from something which is compiled and then decorate
it with your additional HTML. It can't compile each time because whenever
you had an error in your code behind you wouldn't be able to design your
page. So, it shows the most recent ancestor class to ensure everything
looks the way it should before decorating, unfortunately your ancestor class
is abstract.


--
Pete
====
Audio compression components, DIB graphics controls, FastStrings
http://www.droopyeyes.com

Read or write articles on just about anything
http://www.HowToDoThings.com
 
The good news is, it is working in VS2005 beta 1 with no problem - not
that it solves today's problems, but something to look forward to.
 
Back
Top