ASP.NET Abstract Base Classes & Visual Studio#
Not a good mix ;-) Apparently when you try to open a web form in the designer, it will try to create an instance of the base class of your form's code-behind class. Typically, that will be the System.Web.UI.Page class. I can see why that's a good idea in WinForms where you actually see an instance of a Windows Form (System.Windows.Forms.Form) in the designer - but I don't really understand why the web forms designer would do such a thing. Web forms should render html to the browser, and since User Controls aren't even rendered in the webpage you're designing I don't think any other actual rendering is done by the designer, apart from your own html code for the page of course. So why create an instance of the page's base class?

The reason I came across this is that we have some custom base classes for ASP.NET pages and our design required one of those to be abstract since an overriding class should implement a certain method. Now the designer crashes on us if we derive from that since it tries to instantiate an abstract base class - no more forms designer for that page. Maybe there is a good reason for the designer to instantiate a Page object, but at least it could look further up the class hierarchy for a more suitable (i.e. non-abstract) base class if it really needs some instance to do its work.
Blog | Programming | .NET | ASP.NET | Quirks | VS.NET
Comments are closed.
All content © 2012, Jelle Druyts
On this page

Recent Photos
www.flickr.com
This is a Flickr badge showing public photos from Jelle Druyts. Make your own badge here.
Advertising
Top Picks
Statistics
Total Posts: 350
This Year: 0
This Month: 0
This Week: 0
Comments: 530
Archives
Sitemap
Disclaimer
This is my personal website, not my boss', not my mother's, and certainly not the pope's. My personal opinions may be irrelevant, inaccurate, boring or even plain wrong, I'm sorry if that makes you feel uncomfortable. But then again, you don't have to read them, I just hope you'll find something interesting here now and then. I'll certainly do my best. But if you don't like it, go read the pope's blog. I'm sure it's fascinating.

Powered by:
newtelligence dasBlog 2.0.7226.0

Sign In