OnClientClick confirm question

  • Thread starter Thread starter cir9
  • Start date Start date
C

cir9

I know that I can add: return confirm(Are you sure?') to a
button and have the button eventhandler action taken if they choose
yes, but is there any good way to also cause a postback and do some
action on a "Cancel" click ? Like perhaps some optional parameter to
add to that confirm statement?

In old asp.net I used javascript and a hidden field to see if they
clicked yes or no, now in 2.0 I ran across this return confirm(Are
you sure?') thing, which I like, but I want to also perform some
action if they click Cancel, not simply cancel processing. Any simple
built in way to do this nowadays?

thanks.
 
I know that I can add: return confirm(Are you sure?') to a
button and have the button eventhandler action taken if they choose
yes, but is there any good way to also cause a postback and do some
action on a "Cancel" click ? Like perhaps some optional parameter to
add to that confirm statement?

In old asp.net I used javascript and a hidden field to see if they
clicked yes or no, now in 2.0 I ran across this return confirm(Are
you sure?') thing, which I like, but I want to also perform some
action if they click Cancel, not simply cancel processing. Any simple
built in way to do this nowadays?

Still, use a hidden field, and use this JavaScript:
OnClientClick="document.getElementById('myHiddenFieldID').value=confirm('Are
you sure?');return true;"
 
Back
Top