C# – Contents not able to be found in an Update Panel


I have a table for a contact form and this table contains another table which is hidden whether the extended form is desired or not because this control is used on several pages. All of this worked fine until I put an update panel around it. I can see the controls in the code behind and the page builds successfully but when I run it it throws this error:

Object reference not set to an instance of an object.

I am pretty sure that I have done this type of thing before, but it does not seem to work now. Has anyone else ever experienced this?

Best Solution

With the help from a co-worker I figured out my problem.

I was referencing the controls when I was setting a property and apparently properties were getting set before all the controls were being put on the page whereas without the update panel the set was working fine.

If anyone else ever has this problem all you have to do is set a property on the page and in the page load set the control properties as you need to.