Apr 28, 2010 02:44 AM|Jalpesh P. Vadgama|LINK
While taking interview for asp.net 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"/>