Monday, April 19, 2010

Playing with Update Panel in

While taking interview for I often asked questions regarding update panel and how they works and how we can asynchronous post back using update panel without post backing whole page. To my surprise most of people don’t know how to use update panel using triggers. Let’s create simple example to demonstrate use of trigger.

We will take one button and then we will use a textbox control and when button’s click event fires its will change textbox text value and fill textbox with that value. But lot’s people here believes that button should be inside update panel but that’s is not true you can use trigger of a update panel for any control outside update panel.

First let’s take look of server side code of button click. Following is a code for that.

protected void btnHelloWorld_Click(object sender, EventArgs e)
    txtHello.Text = "This is without postback";

here it will simple fill the textbox with string “This is without post back”. Now lets create trigger like following.

<asp:ScriptManager ID="myScriptManager" runat="server">
<asp:UpdatePanel ID="updTextbox" runat="server">
    <asp:TextBox ID="txtHello" runat="server"></asp:TextBox>
    <asp:AsyncPostBackTrigger ControlID="btnHelloWorld" EventName="Click" />
<asp:Button ID="btnHelloWorld" runat="server" Text="Submit" onclick="btnHelloWorld_Click"/>

It’s simple and you don’t need button insides the update panel. Hope this will help you.

Technorati Tags: ,,,

Shout it

kick it on


  1. Hi

    Tks very much for post:

    I like it and hope that you continue posting.

    Let me show other source that may be good for community.

    Source: Panel interview questions

    Best rgs

  2. it's very useful post....
    As this question is ask so many time in the interview

    Good one


  3. it works without triggers part. then what is the use of triggers?

  4. @ Swagat- Trigger are for specific events. If you don't specify the trigger it will update every time if any event of any control in update panel will fire. That will be a performance problem. So if you specify trigger it will update once that event will fire. Like in above example we have click event of button. So it will update only on click event of button.


Your feedback is very important to me. Please provide your feedback via putting comments.

About Me
My Photo

Full Stack Developer,Blogger,Microsoft Mvp, Mentor, Life long learner, 10+ Years of Experience for JavaScript, web and Microsoft technologies. ASP.NET MVC,Web Forms,C#,AngularJs,Golang
Mvp profile
Subscribe to my blog

Enter your email address:

Follow us on facebook
Blog Archive
Total Pageviews