tags:

views:

696

answers:

2

I have the following ASPX structure:

<UpdatePanel id="OutsidePanel" UpdateMode="Conditional">
  <div runat="server" id="myDiv">
    <UpdatePanel id="InsidePanel" UpdateMode="Conditional">    

     <asp:ImageButton that causes a postback.. />
   </UpdatePanel>
  </div>
</UpdatePanel>

When the imageButton is clicked, on the server side, I change the class of myDiv. It's not getting updated. I assume this is because the div is outside of the Inside UpdatePanel. How would I force it to update?

A: 

If you are updating the class server-side, then the answer is yes. The inner update panel is being rerendered and passed back to the client, but the outer update panel is not being replaced. Anything outside the actual panel being updated won't be replaced when the AJAX callback returns. You might want to consider adding some javascript that updates the div when the result is returned as a simple solution to changing the class.

tvanfosson
Thanks.I guess in this situation, I can do away with a JS solution. However, I am curious to know if there's a server side solution to this?
DotnetDude
A: 

Could you not just call the Update method of the "OutsidePanel" UpdatePanel on the server when the Imagebutton in "InsidePanel" causes a postback? Or alternatively, set up ImageButton click event as a trigger for "OutsidePanel"

According to MSDN

If the UpdateMode property is set to Conditional, the UpdatePanel control's content is updated in the following circumstances:

  • When you call the Update method of the UpdatePanel control explicitly.

  • When the UpdatePanel control is nested inside another UpdatePanel control, and the parent panel is updated.

  • When a postback is caused by a control that is defined as a trigger by using the Triggers property of the UpdatePanel control. In this scenario, the control explicitly triggers an update of the panel content. The control can be either inside or outside the UpdatePanel control that the trigger is associated with.

  • When the ChildrenAsTriggers property is set to true and a child control of the UpdatePanel control causes a postback. Child controls of nested UpdatePanel controls do not cause an update to the outer UpdatePanel control unless they are explicitly defined as triggers.

Russ Cam
If you are always going to update the outer panel when the inner panel is updated, I don't see much point in using the inner one. I could see the value in this if only some triggers from the inner panel updated the outer panel.
tvanfosson
Interesting. Where do I call the OutsidePanel's Update(). Is there an event handler for this?
DotnetDude
tvanfosson - This is a snippet of the full code. The actual code has several Inner Update Panels within the OutsideUpdatePanel. So, I cannot really combine both the panels.You bring out an interesting Q though. How would I selectively update only some controls outside the one causing the postback?
DotnetDude
@tvanfosson- Agreed
Russ Cam
@DotnetDude - You simply need only call OutsidePanel.Update() in your ImageButton click event handler
Russ Cam