Click here to Skip to main content
Licence 
First Posted 1 Jul 2002
Views 59,480
Bookmarked 27 times

Watch Out for this Web Form Designer issue

By | 2 Jul 2002 | Article
If your web form designer stops working, this might be a reason why...

The problem

If you see the following error when trying to load your web form designer :-

The class file for this Web Form was not loaded. 
Close this view, correct any errors, then reopen the Web Form.

Then you might have to check the code behind for your web form carefully. VS.NET complains if you have declared a class in your aspx.cs file in the following manner :-

public class CustomDropDown : Control //yada yada
public class WebForm1 : System.Web.UI.Page
{
    //yada yada
}

In other words, you have created a class outside the web form's Page class. The weird thing is that it will compile just fine. But when you try to visit the web form designer for your page, you'll either get the error message I described, or your web designer will behave in a funny manner.

The quick solution

Remove the offending class and either place it within your Page class or in a separate class file (my preferred solution).

Thoughts

Some of you might know the technical reason for this behavior and as such might scoff at this "obvious" workaround, but my argument is that the code compiles fine. As such it shouldn't have such a drastic effect on the forms designer in my opinion. And the error message implies that your code is wrong, which I don't think it is. But if anyone can educate me, then please let me know what is the difference between declaring a class outside my Page class (but within the same namespace) and in a separate file altogether (again within the same namespace)

Another Workaround (update)

Jamie Nordemeyer informs me that placing the above class simply under the Page class also solves the problem.

public class WebForm1 : System.Web.UI.Page //yada yada
public class CustomDropDown : Control //yada yada

Thanks Jamie!!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Senkwe Chanda

Web Developer

South Africa South Africa

Member

Nada

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralThe reason PinmemberAlpha Nerd8:36 2 May '08  
GeneralAnother Solution PinmemberJamie Nordmeyer7:55 2 Jul '02  
GeneralRe: Another Solution PinmemberSenkwe Chanda21:27 2 Jul '02  
GeneralRe: Another Solution PinmemberJamie Nordmeyer4:57 3 Jul '02  
GeneralRe: Another Solution PinmemberMartin Pilot15:06 3 Jul '02  
GeneralRe: Another Solution PinmemberMartin Pilot15:06 3 Jul '02  
GeneralRe: Another Solution PinmemberSenkwe Chanda3:09 5 Jul '02  
GeneralRe: Another Solution PinmemberChristopher Kimbell7:13 10 Nov '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 3 Jul 2002
Article Copyright 2002 by Senkwe Chanda
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid