Tuesday, October 26, 2010

 

Error Creating Control

I recently came across this error in a web app I had taken over from a previous developer. The app compiled fine, and ran just fine too.

The pain is caused when you need to adjust properties via the smart tag of the control. The control is no longer visible, so the only way to make the adjustments is to hand code the markup code. That can be slow, and in my case, impossible as it was a control I was not familiar with.

After much Googling, and filtering out results that dealt with VS2003, 2005, 2008, I found a solution.
VS2010 is doing a lot of things in the background, like checking your web.config file and your session variables.

Now the link at the beginning of this post refers to the OnInit() method. If you don't use this method, you may need to check your Page_Init() method.

If you are coding in VB then place this snippet at the beginning of the Sub

If Not DesignMode Then
If Context IsNot Nothing AndAlso Context.Session IsNot Nothing Then

... your code goes in here...

End If
End If

If you code in C# then place this snippet at the beginning of your method

If (!this.DesignMode)
{
... your code goes in here...
}

Save and Close the page/s, Clean and Rebuild your project.
You should now be able to see your controls again :-)

Labels: ,


Comments:
This comment has been removed by a blog administrator.
 
Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]