UpdatePanelAnimationExtender - OnUpdating Will Always Play
Did you know that the when a partial postback starts, the OnUpdating animation for all of the UpdatePanelAnimationExtender's on the page will play. Here is part of the documentation taken from the UpdatePanelAnimationExtender page
It is important to note that because of the UpdatePanel architecture, the OnUpdating animation will always play when any partial postback starts, but the OnUpdated animation will only play at the end of a partial postback if its UpdatePanel was changed (note: setting the UpdatePanel's UpdateMode="Always" will ensure the OnUpdated animation plays when every partial postback completes).
Unless I am mistaken, I believe this behavior is for the scenario where an UpdatePanel's UpdateMode is set to Conditional, and the code on the server handling the partial postback explicitly calls Update on the UpdatePanel. In this case, where logic on the server decides if an UpdatePanel is refreshed, the UpdatePanelAnimationExtender has no way of knowing if it should have played the OnUpdating animation before requesting the partial postback.
Why is this important? If in your OnUpdating animation you disable controls, display a progress bar, or modify the DOM in any other way that is reversed by the OnUpdated animation you will not have the opportunity to undo these effects. Here is a quick sample of this. I created a web page that contains 2 UpdatePanels, both have their UpdateMode set to 'Conditional' and both with corresponding buttons that trigger partial postbacks. An UpdatePanelAnimationExtender is created for each UpdatePanel and is responsible for disabling and re-enabling the buttons that trigger the postbacks.
<asp:Button ID="btnRefreshCustomers" runat="server" Text="Refresh Customers" /> <asp:UpdatePanel ID="udpCustomers" runat="server" UpdateMode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnRefreshCustomers" /> </Triggers> <ContentTemplate> <asp:GridView runat="server" DataSourceID="sqldsCustomers" /> </ContentTemplate> </asp:UpdatePanel> <cc1:UpdatePanelAnimationExtender runat="server" TargetControlID="udpCustomers"> <Animations> <OnUpdating> <EnableAction AnimationTarget="btnRefreshCustomers" Enabled="false" /> </OnUpdating> <OnUpdated> <EnableAction AnimationTarget="btnRefreshCustomers" Enabled="true" /> </OnUpdated> </Animations> </cc1:UpdatePanelAnimationExtender>
Because the OnUpdating animation runs for all UpdatePanelAnimationExtenders, when the 'Refresh Orders' button is clicked, both buttons are disabled (both OnUpdating animations are played), but because only the Orders panel was updated, only the Orders OnUpdated animation is run. As a result the 'Refresh Customers' button is left disabled and the page is now broken. You can try out the demo site here.
One alternative, as pointed out by the documentation, is to make sure all UpdatePanel's on your page have the UpdateMode set to 'Always' (this is the default value). Of course doing this means that any partial postback that occurs on the page will update the contents of all of the UpdatePanels, which may be unnecessary.
Hmm ... is this a glitch in the Matrix?