How to disable postback on an asp Button (System.Web.UI.WebControls.Button) How to disable postback on an asp Button (System.Web.UI.WebControls.Button) asp.net asp.net

How to disable postback on an asp Button (System.Web.UI.WebControls.Button)


Have your javascript return false when it's done.

<asp:button runat="server".... OnClientClick="myfunction(); return false;" />


YourButton.Attributes.Add("onclick", "return false");

or

<asp:button runat="server" ... OnClientClick="return false" />


You can use jquery click action and use the preventDefault() function to avoid postback

<asp:button ID="btnMyButton" runat="server" Text="MyButton" />$("#btnMyButton").click(function (e) {// some actions here e.preventDefault();}