OnClientClick confirm question

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.
 
R

Riki

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;"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top