Asp.net Ajax UpdatePanel Mode


The ASP.NET Ajax UpdatePanel is that its contents are updated asynchronously when an event that normally generates a postback event is raised inside page. UpdateMode property of the UpdatePanel has 2 possible values:
  • Always (Default value)
  • Conditional
When it’s by default 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.
Note: for multiple update panels and if you don't want to update all of them to be updated every time, you have to set the UpdateMode to Conditional.
Here is the simple example:
"frmUpdatePanel" runat="server">
"ScriptManager1" runat="server">
"UpdatePanel1" runat="server" UpdateMode="Conditional">
<asp:Label ID="lblMsg1" runat="server" runat="This is Button1 clicked without postback" >asp:Label>
"Button1" runat="server" Text="Button" />


"UpdatePanel2" runat="server" UpdateMode="Conditional">
<asp:Label ID="lblMsg2" runat="server" runat="This is Button2 clicked without postback" >asp:Label>
"Button2" runat="server" Text="Button" />
In the above code, Button1 will only update UpdatePanel1 and Button2 will update UpdatePanel2.

Comments