AVoid Postback on OnClick Event
-
21-09-2019 - |
Question
I have a Javascript
function
show()
{
alert("hello");
}
which runs on ASP Button OnClick Event.
When I click the button of alert message box showing "hello", postback occurs. Is there any way I cant prevent this postback?
Solution
Try:
return false;
OTHER TIPS
Yes, you can do show(); return false;
in the button's onclick handler.
onclick="show();return false;"
it's very simple: insert aber the "Alert('msg');" a "return false;".
so:
function show()
{
alert('Hallo');
return false;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow