472,811 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 software developers and data experts.

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

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!
Nov 18 '05 #1
1 2538
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"
<an*******@discussions.microsoft.com> 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!


Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Brent | last post by:
I'd like to subclass the built-in str type. For example: -- class MyString(str): def __init__(self, txt, data): super(MyString,self).__init__(txt) self.data = data
0
by: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520"...
17
by: Rodusa | last post by:
I am getting this exception error which is driving me nuts. System.NullReferenceException - Object reference not set to an instance of an object If I comment this line, I don't get any errors:...
1
by: S Guiboud | last post by:
I want to subclass the System.Web.UI.UserControl to make a common control for my site. Then, when I create a new UserControl from the Visual Studio I changed the base class...
3
by: Patrick.O.Ige | last post by:
I'm loading an Array below but getting the error "Object reference not set to an instance saying 'ItemNumber = CType(Args.Item.FindControl("ItemNumber"), TextBox).Text' is the error line. I DON'T...
3
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
2
by: Ryan | last post by:
Hi, I receive an access denied error (see below) when attempting to send an email with BodyFormat=MailFormat.Html from an asp.net page. Exactly the same code works fine in a console...
3
by: forest demon | last post by:
for example, let's say I do something like, System.Diagnostics.Process.Start("notepad.exe","sample.txt"); if the user does a SaveAs (in notepad), how can i capture the path that the user...
1
by: differentsri | last post by:
THIS IS AN ASP.NET 1.1 APPLICATION IAM TRYING TO UPDATE THE FIELD BUT I AM NOT ABLE TO UPDATE IT? CAN U TELL THE REASON ? IT IS GIVING THE FOLLOWING ERROR BELOW I HAVE ALSO GIVEN THE CODE OF...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.