Click here to Skip to main content
15,909,332 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have asp button I want avoid pageload on button click

What I have tried:

I have used autopostback,onclientclick
Posted
Updated 7-Aug-18 20:10pm
Comments
Richard Deeming 7-Aug-18 14:23pm    
<asp:button runat="server" ... OnClientClick="return false;" />


But if the button isn't going to do anything, then there's not much point in it being there.

1 solution

In your Aspx file use OnClientClick

<asp:Button1 runtat="server" OnClientClick="return false"

Or if you want to handle it in your code behind file then you should add this as a attribute to your button: like

Button1.Attributes.Add("onclick", "return false;");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900