How to disable postback on an asp Button in System Web UI WebControls Button

0 votes
I have an asp button. It's server-side so I can only show it for logged in users, but i want it to run a javascript function and it seems when it's runat="server" it always calls the postback event.

I also have a regular button (<input...>) not running at server and it works fine...

How can I make this button only run the javascript and not postback?
Sep 9, 2020 in Java-Script by kartik
• 37,510 points
1,823 views

1 answer to this question.

0 votes

Hello @kartik,

Use this:

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

Hope it work!!

Thank You!!

answered Sep 9, 2020 by Niroj
• 82,880 points

Related Questions In Java-Script

0 votes
1 answer

How to check Page.Validate() on client side (JavaScript) in ASP.Net?

Hello @kartik, Page_ClientValidate() will work. It returns true if ...READ MORE

answered Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
3,141 views
0 votes
1 answer

How can we detect timeout on an AJAX (XmlHttpRequest) call in the browser?

Hii, In order to handle a timeout: var xmlHttp ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,880 points
5,134 views
0 votes
1 answer

How to include csrf_token() in an external js file in Laravel?

Hello @kartik, To resolve this error you can ...READ MORE

answered Jun 11, 2020 in Java-Script by Niroj
• 82,880 points
3,465 views
0 votes
1 answer

How to Intercept call to the back button in my AJAX application?

Hello @kartik, It is very easy toi disable ...READ MORE

answered Jun 18, 2020 in Java-Script by Niroj
• 82,880 points
4,250 views
0 votes
1 answer

Why it is necessary to refresh CSRF token per form request?

Hello, Generating a new CSRF token for each ...READ MORE

answered Mar 19, 2020 in Laravel by Niroj
• 82,880 points
4,147 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
2,960 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
1,011 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
3,036 views
0 votes
1 answer

How to call jQuery UI Dialog with ASP.NET button postback?

Hello @kartik, To solve the problem with ASP:Button ...READ MORE

answered Apr 28, 2020 in Java-Script by Niroj
• 82,880 points
3,128 views
0 votes
1 answer

How to disable asp.net button after click to prevent double clicking?

Hello @kartik, On the front end, add these ...READ MORE

answered Sep 9, 2020 in Java-Script by Niroj
• 82,880 points
7,746 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP