welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Wednesday, March 14, 2012

How to avoid button postback in

In some cases we need to use button as only onclient click event,in that case we don’t  like the postback of button control.
To avoid the button postback the following code has helpful to solve the problem…..
  <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick ="scrfn();return false;" />

In button control just add only the return false in on client click event…Also if need to call any script function you can as its in on client click event….
Second method adds the below code in load event to avoid button post back…..
Button1.Attributes.Add("onclick", "return false;")

I hope you like this technique to avoid the button postback…


Post a Comment