views:

153

answers:

1

I just switched to VS 2010, and upgraded a previous project. I'm getting the following error on a page in design mode for 2 controls:

Error Creating Control - ObjectName 
Object reference not set to an instance of an object.

One of them is a simple label, and the other is a ajax update panel. Other pages look fine. When I build and test the app, the page renders fine in the browser and functions fine - the label functions as expected and the content in the update panel works as expected.

Any ideas why I'm getting this error? I tried some of the google results to no avail. It'd be great to get this out of the way.

Thanks!

A: 

This error can occur when the Designer in Visual Studio instantiates an instance of a server control or composite control. It will attempt to read readable properties that may map to objects inside your control that have yet to be initialized. If you have a custom server control you need to override the CreateChildControls method of the base Control calls and inside it initialize any objects your properties depend on and then in the properties call the base EnsureChildControls method.

This will ensure that all of the dependent objects in your control are initialized before they're referenced.

CptSkippy
Hmm - any ideas why I'm getting it on this label: <asp:Literal id="AssessType" runat="server" Text="Self"/>I'm using built in tools - Ajax update panel, etc., and the one custom control I have on the page displays fine on another page when viewed in the designer.This is a bit confusing, because I looked at it in VS 2008 on another machine, and it displays fine.I think it might be something trivial I might be overlooking - I didn't change the page from when it displayed fine. Maybe VS 2010 has stricter standards?
stringo0