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

Discussion in 'ASP .Net' started by =?Utf-8?B?Q2h1Y2sgSGFlYmVybGU=?=, Feb 20, 2004.

  1. 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!
     
    =?Utf-8?B?Q2h1Y2sgSGFlYmVybGU=?=, Feb 20, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?Q2h1Y2sgSGFlYmVybGU=?=

    Mike Bridge Guest

    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"
    <> 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!
     
    Mike Bridge, Feb 20, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S Guiboud
    Replies:
    1
    Views:
    415
    Ross Dempster
    Jul 18, 2003
  2. DanG
    Replies:
    4
    Views:
    9,654
  3. Steve B.
    Replies:
    4
    Views:
    989
    Cheryl D Wise
    Jun 1, 2007
  4. Alexander Higgins
    Replies:
    3
    Views:
    1,093
    Teemu Keiski
    Jul 30, 2007
  5. Alexander Higgins
    Replies:
    0
    Views:
    457
    Alexander Higgins
    Jul 21, 2007
Loading...

Share This Page