client side script for confirm box

sdlangers

Centurion
Joined
Dec 3, 2002
Messages
118
hi,

i need a different version of this code - all the examples i found are for prompting 'are you sure you want to delete?'

btnDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete?');")

and if ok is clicked, the server side function executes, and if cancel is clicked, it doesnt

what i need is if ok is clicked server function 'A' is called and if cancel is clicked, server function 'B' is called - or alternatively, one funciton is called with a parameter that lets me know if the user clicked ok or cancel

any ideas?
 
Instead of useing the confirm dialog, you could use a simple small web page with your message and 2 buttons on it and open it as a Modal Dialog using javascript. The modal dialog would return a value and you can determine that value and take appropriate action.
 
Thanks,

but i was hoping there is an easier way - the confirm button does it - but i just cant trap the cancel - i thought there might be a way of sending the 'cancel' response back to the server side code and not just the 'ok' response
 
You can add the word "javascript:" before your "return"

or

btnDelete.Attributes("onclick") = "javascript:return " & _
"confirm(''Are you sure you want to delete?')"
 
Back
Top