tags:

views:

21

answers:

1

I have the following command to delete button.

DeleteButton.Attributes.Add("Onclick", "javascript:return confirm(Are you sure?" + ");");

I want to know what the user has clicked(Ok/Cancel) on the server side to continue with delete.

How can this be achieved? code snippet or example would be great.

+2  A: 

since you're relying on javascript for the confirmation, you can stop the delete action before it gets submitted to the server.

DeleteButton.Attributes.Add("Onclick", 
    "if ( ! confirm('Are you sure?') ) { return false; }" );

keep in mind that if the user has javascript disabled, all of this is going to doing absolutely nothing. you should have a backup method of verification that operates server-side.

lincolnk
I am able to get to Page_Load. How can I identify that this is from the javascript confirm box?
Kalls
Ok I have the server side delete button event as well.Onclick of OK on javascript Confirm it takes me back to the event. If the user presses cancel button on javascript confirm window it stays on the same page. It solves my issue. I appreciate your answer.
Kalls