UpdatePanel behavior: Conditional or Always?

Damir Dobric Posts

Next talks:



Follow me on Twitter: #ddobric




ASP.NET AJAX framework (ATLAS) is shipped with a powerful control UdatePanel. The control offers very easy way to build responsive applications. However it provides also some few different behaviors which every developer should know. In this context the UpdateMode property of the UpdatePanel is considered. Imagine, there is a page with three TextBox-es. Two of them are placed inside of update panels (one in each) and one of them is out UpdatePanels. The first UpdatePanel has UpdateMode set on Conditional and the second one on Always.

Additionally, Inside of both UpdatePanel-s, there is one button. Without of spending lot of words, take a look on the following example:

 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="GadgetTestWebApplication.WebForm3" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>



<form id="form1" runat="server">



<atlas:ScriptManager ID="SM" runat="server" EnablePartialRendering="true"></atlas:ScriptManager>


<atlas:UpdatePanel UpdateMode="Conditional" ID="panel1" runat="server">


<asp:Button ID="cmd" Text="Conditional" runat="server" OnClick="cmd_Click" />

<asp:TextBox ID="a1" runat="server"></asp:TextBox>




<atlas:UpdatePanel UpdateMode="Always" ID="panel2" runat="server">


<asp:Button ID="Button1" Text="Always" runat="server" OnClick="cmd_Click" />

<asp:TextBox ID="a2" runat="server"></asp:TextBox>




<asp:TextBox ID="a3" runat="server"></asp:TextBox>






When any of buttons is pressed the content of all three TetxBox-es is set on the current time as shown in the following code:

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;


namespace GadgetTestWebApplication


public partial class WebForm3 : System.Web.UI.Page


protected void Page_Load(object sender, EventArgs e)





protected void cmd_Click(object sender, EventArgs e)


a3.Text = DateTime.Now.ToString();

a2.Text = DateTime.Now.ToString();

a1.Text = DateTime.Now.ToString();





The question is: "What will happen with the content of TextBox-s when buttons are pressed?"

Here is the answer:

  1. When any of buttons is pressed, the third textbox (a3) will never be updated.
  2. When the second button is pressed (a2) the second TextBox (a2) will be updated.
  3. When the first button is pressed the first and second buttons (a1 and a2) will be updated.


One more interesting behavior can be foundhere.

Posted Feb 02 2007, 01:04 AM by Damir Dobric
Filed under:
developers.de is a .Net Community Blog powered by daenet GmbH.