Updatepanel is used to perform partial postback of the page. UpdatePanel eliminates the need of a refresh of the whole page in each
postback request. This control is located inside Ajax Extensions tabs inside a toolbox.

The can have two childtags.
1. ContentTemplate: The content can be any valid tag that you normally put on your page, from literal text to web controls or data contol.
2. Trigger: The Triggers tag allows you to define certain triggers which will make the panel update it’s content.

In the following example,’Update Both’ button cause update of both updatepanel whereas ‘Update’ will update only main updatepanel.
You need to add a ScriptManager tag while using any Ajax contol in asp.net web form application.

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
     <form id="frmMain" runat="server">
        <asp:ScriptManager ID="smMain" runat="server" />
        <asp:UpdatePanel runat="server" id="upMain" updatemode="Conditional">
            <asp:AsyncPostBackTrigger controlid="btnUpdate2" eventname="Click" />
                <asp:Label runat="server" id="lblDateTimeLabel1" />
                <asp:Button runat="server" id="btnUpdate1" onclick="UpdateButton_Click" text="Update" />               
        <asp:UpdatePanel runat="server" id="upSub" updatemode="Conditional">           
                <asp:Label runat="server" id="lblDateTimeLabel2" />
                <asp:Button runat="server" id="btnUpdate2" onclick="UpdateButton_Click" text="Update Both" />



protected void UpdateButton_Click(object sender, EventArgs e)
  lblDateTimeLabel1.Text = DateTime.Now.ToString();
  lblDateTimeLabel2.Text = DateTime.Now.ToString();

Try running above example, and observe the effect of both buttons. You can notice that first button update only first datestamp whereas second button cause update of both datestamps.
The AsyncPostBackTrigger tag is also easy to understand- it takes only two attributes, the controlid, a reference to the control which can trigger it, and the eventname, which tells which event type will cause the trigger to fire.

Read :


You can also read about ASP.NET,C#.NET, JQUERY, AJAX.
I hope you get an idea about UpdatePanel control in ASP.NET.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you liked this post, don’t forget to share this.

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *