Follow in Twitter & Facebook



Like in Facebook

Powered By Blogger Widgets

Free Download

FREE Tools



Tuesday, August 28, 2012

asp.net updatepanel refresh page

In this article we will discuss how we can refresh a page from a button click inside a updatepanel. Also you can check my last article on Ajax Progress bar in Asp.Net.

As I have explained in my last article on Ajax updatepanel example in asp.net, button click will not do postback. Suppose there are 2 buttons, in 1 button I want to do postback, remember since the button is inside the UpdatePanel so it will not do postback. We can do postback by using asp:PostBackTrigger control.
Below is the HTML code:

<!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></title></
head><
body><form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate>
<asp:Button ID="btnAjaxNoRefresh" runat="server" Text="Click for no refresh !" OnClick="btnAjaxNoRefresh_Click" />
<br />
<asp:Button ID="btnDoPostBack" runat="server" Text="Click for Postback !" OnClick="btnDoPostBack_Click" />
</ContentTemplate>
<Triggers><asp:PostBackTrigger ControlID="btnDoPostBack" /></Triggers>
</asp:UpdatePanel>
<div></div></form></
body></
html>
ControlID: ID of the button on which we need postback.




0 on: "asp.net updatepanel refresh page"