Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Subclassing from System.Web.UI.Page - Designer Error

Reply
Thread Tools

Subclassing from System.Web.UI.Page - Designer Error

 
 
=?Utf-8?B?Q2h1Y2sgSGFlYmVybGU=?=
Guest
Posts: n/a
 
      02-20-2004
We have need to share functionality across all of our application web pages, so we decided to subclass from System.Web.UI.Page. When we create a new aspx, the Visual Studio designer automatically puts in the codebehind, as such:

public class testsubclass : System.Web.UI.Page

We change this to be:

public class testsubclass : OurProject.Library.BaseWebPage

Which is defined as:

public class OurProject.Library.BaseWebPage : System.Web.UI.Page

The application will compile and run and all inheritance operates as expected. However, the designer stops working with the aspx file.

If you have the aspx file closed and open it, you get only an editor for the raw HTML, the designer will not open and the error:

An exception occurred while trying to create an instance of OurProject.Library.BaseWebPage. The exception was "Object reference not set to an instance of an object."

It also says: make sure all of the classes used in the page are built or referenced in the project.

I've tried opening it with the Library project which contains BaseWebPage included in the solution, and I've tried it with the Library project being compiled and the resulting DLL referenced. (Debug compile only...)

If you revert the testpage back to System.Web.UI.Page and close and reopen the aspx file, the designer works properly. If you have the designer open and then change it back to the subclass type derived from Page, the error occurs and while the designer stays open, the toolbox controls stop working and the designer is rendered useless.

Any advice would be most apprciated!
 
Reply With Quote
 
 
 
 
Mike Bridge
Guest
Posts: n/a
 
      02-20-2004
Have you tried this with VS.net 2003? I had problems inheriting a
code-behind from a superclass in VS.net 2002, but they all disappeared
when I upgraded.

-Mike



On Fri, 20 Feb 2004 06:06:05 -0800, "Chuck Haeberle"
<(E-Mail Removed)> wrote:

>We have need to share functionality across all of our application web pages, so we decided to subclass from System.Web.UI.Page. When we create a new aspx, the Visual Studio designer automatically puts in the codebehind, as such:
>
>public class testsubclass : System.Web.UI.Page
>
>
>We change this to be:
>
>public class testsubclass : OurProject.Library.BaseWebPage
>
>Which is defined as:
>
>public class OurProject.Library.BaseWebPage : System.Web.UI.Page
>
>The application will compile and run and all inheritance operates as expected. However, the designer stops working with the aspx file.
>
>If you have the aspx file closed and open it, you get only an editor for the raw HTML, the designer will not open and the error:
>
>An exception occurred while trying to create an instance of OurProject.Library.BaseWebPage. The exception was "Object reference not set to an instance of an object."
>
>It also says: make sure all of the classes used in the page are built or referenced in the project.
>
>I've tried opening it with the Library project which contains BaseWebPage included in the solution, and I've tried it with the Library project being compiled and the resulting DLL referenced. (Debug compile only...)
>
>If you revert the testpage back to System.Web.UI.Page and close and reopen the aspx file, the designer works properly. If you have the designer open and then change it back to the subclass type derived from Page, the error occurs and while the designer stays open, the toolbox controls stop working and the designer is rendered useless.
>
>Any advice would be most apprciated!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Designer Property Serialization -- Sycning inner properties to designer property window Alexander Higgins ASP .Net Building Controls 3 07-30-2007 09:09 PM
Designer Property Serialization -- Sycning inner properties to designer property window Alexander Higgins ASP .Net Web Controls 0 07-21-2007 12:58 AM
Sharepoint Designer/ Expression Web Designer : adding item in toolbox ? Steve B. ASP .Net 4 06-01-2007 04:29 AM
subclassing a module: misleading(?) error message Erik Johnson Python 4 01-11-2007 06:50 PM
Subclassing UserControl makes the Visual Studio designer does not work S Guiboud ASP .Net 1 07-18-2003 03:55 PM



Advertisments