Thursday, August 20, 2009

UpdateProgress is not working with AssociatedUpdatePanelID

Somebody found the UpdateProgress isn't working if it sets the property "AssociatedUpdatePanelID". Actually, when the Trigger control is outside UpdatePanel, and AssociatedUpdatePanelID of UpdateProgress is pointing to this UpdatePanel, the UpdateProgress won't be working.In the following sample, UpdateProgress AssociatedUpdatePanelID is pointing to UpdatePanel1, and Button1 which is the trigger control is outside UpdatePanel1. When you click the Button1, UpdateProgress will not be working.

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
Current Time <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />

If Button1 is inside UpdatePanel1, the value of postBackSettings.PanelID will be generated to "UpdatePanel1Button1". AssociatedUpdatePanelID will be checked with postBackSettings.PanelID. If they are equel, UpdateProgress will be displayed.If Button1 is outside UpdatePanel1,the value of postBackSettings.PanelID will be generated to "ScriptManager1Button1". AssociatedUpdatePanelID is not matched with it, so it can't pop out UpdateProgress.In this case, we have to show UpdateProgress manually when the value of is button1.