I wanna do something in javascript before page goes for post back.
How to run a javascript function before any asp.net postback?
$('form').submit(function () {
alert('hello');
});
It doesn't work... :(
I wanna do something in javascript before page goes for post back.
How to run a javascript function before any asp.net postback?
$('form').submit(function () {
alert('hello');
});
It doesn't work... :(
try this?
If you want to do something client-side before asp's postback, try using the
OnClientClick
attribute of theasp:button
, eg:try:
The form won't be submitted unless you return
true
and before that you can do all you want. It doesn't have to be aconfirm()
call of course.I find the way, in the asp.net forums and it was a some code in codebehind.
Just add this to your Page_Load event handler, changing the javaScript string to what you want to happen.