views:

162

answers:

2

I have come across what seems to be an annoying bug with asp.net UpdatePanels in 2 seperate projects. If you have some kind of autopostback enabled control that can cause all of the controls in the update panel to have visible=false set, resulting in an empty update panel.

When you change the autopostback control back to the postion that would re enable all of the controls in the update panel, it simply does not make a call back to the server and the update panel does not update.

If you do anything else that makes a call back on the same page, then the update panel contents magically appear. It is as if asp.net has decided the update panel is empty so there is no point maikng a callback, even though making the call back would fill the updatepanel with content.

The only way round this is to add a style of display:none to the controls instead of setting visible=false property.
Then it works fine.

Has anyone else encountered this problem? Is it a bug as i suspect or is it likely i am doing soemthing wrong? I haven't got time to post example code at the moment as the code i am using is too wrapped up in other unrealted things, if people think it would help i will create a simple example and post it when I get time.

A: 

The control with AutoPostBack="true" must be set as a AsyncPostBackTrigger of the UpdatePanel.

DavRob60
Yes I am aware of that, and it is. The problem is that it does not always fire. The problem is that if you change the control that is the AsyncPostBackTrigger and the result of the AsyncPostBack is to render the contents of the UpdatePanel innvisible. When you change the control back to the original state, it simply does not trigger an AsyncPostBack. The AsyncPostBackTrigger and AutoPostBack properties are being set in the asp.net markup so are fixed and there is no possibility that these properties could change as a result of an AsyncPostBack.
Ben Robinson
Then how about adding a "asp:HiddenField" in the update panel?
DavRob60
A: 

Putting the control that triggers the asyncpostback, inside the update panel fixes this. I would definately say this is a bug as the only difference is that it works when the control is inside the updatepanel and does not when it is outside the update panel.

Ben Robinson