[Interview quiz] What is the Ajax UpdatePanel

what is the Update panel in asp.net?

Just the Answer

The ASP.NET UpdatePanel control enables you to add AJAX functionality in to the web page. It can be used to update the selected parts of the page instead of refreshing the whole page with a postback. You can say that we can perform the Partial-page rendering using the UpdatePanel control in ASP.Net.

How to Insert UpdatePanel in your ASP.Net web page

1. Create a new web page page.
2. From the toolbox, in the AJAX Extensions tab of the toolbox, double-click the ScriptManager control to add it to the page.

Update panel on the page

3.Double-click the UpdatePanel control to add it to the page.

An Example

The following example contains a ScriptManager control and an UpdatePanel control on a page.

[ASP.Net web page]

 <%@ Page Language="C#" AutoEventWireup="true" 
CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <form id="form1" runat="server">
    <asp:ScriptManager EnablePartialRendering="true" 
    ID="ScriptManager1" runat="server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <asp:Label ID="Label1" runat="server" text="Authorcode"/><br />
                <asp:Button ID="Button1" runat="server" 
                Text="Change the Text" OnClick="Button1_Click" />

[C# code page]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
    public partial class _Default : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
        protected void Button1_Click(object sender, EventArgs e)
            Label1.Text = "Welcome to Authorcode";

In the above example the UpdatePanel control contains a label and Button control. The text of the lavel control refreshes when you click it without whole page refresh.