Since the cool thing about the ASP.NET Ajax UpdatePanel is that its contents are updated asynchronously when an event that would normally generate a postback is raised inside, one would think that this is its default behavior.

But it's not: the UpdateMode property of the UpdatePanel has 2 possible values:

  • Always
  • Conditional

and the default value is Always.

When set to Always, the UpdatePanel is updated on every postback raised from anywhere in the page, so from controls inside the panel, inside other panels or just on the page.

When set to Conditional, the UpdatePanel will be updated only on postback originated by controls inside the panel or from the triggers specified.

So, if you have multiple update panels and you don't want to update all of them to be updated every time, you have to set the UpdateMode to Conditional:

<asp:UpdatePanel ID="UpdatePanel1" 
                  UpdateMode="Conditional"
                  runat="server">

I spent all the day trying to understand why it took so long to refresh a small area with only a few labels, and it was because I didn't set the UpdateMode to Conditional.

I don't understand why the default is Always and not Conditional, but not that I know, it's not a big deal: just have to remember to always set the UpdateMode.

Technorati tags: , ,