Can't derive from abstract web page

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
 
P

Peter Morris

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
 
H

Henke

Ok, that answers my question anyway, but I think it's quite odd though...
Thanks!

/Henke
 
P

Peter Morris

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
 
S

Scott Allen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top