Capturing user response using Javascript confirm message from codebehind

381 views Asked by At

Currently I'm utilising ScriptManager.RegisterStartupScript to display javascript alert message to user in this way:

ScriptManager.RegisterStartupScript(this, GetType(), "Alert Message", "alert('Save Successful!');", true);

What I'm trying to achieve is using ScriptManager.RegisterStartupScript to display a confirmation message to user, and retrieve either a 'Yes' or 'No' response from user. I know this can be done with: MessageBox.Show("Are you sure?", "Confirm?", MessageBoxButton.YesNo) == DialogResult.Yes;

However windows confirmation message box always gets displayed behind and user often don't realize there's a message box being displayed.

How can I achieve this using ScriptManager.RegisterStartupScript?

Much thanks.

1

There are 1 answers

2
Brian Mains On

You can't display a yes/no response, then process the result of that confirmation on the server, unless you postback to the server again, or call a web service and act on it via AJAX.

To follow up, answering yes/no triggers what within the page?