Reputation: 2633
I have some code that looks like this, all in codebehind...
var script = "confirm('Would you like to close this order?')";
ClientScript.RegisterStartupScript(typeof(Page), "CloseOrder", script, true);
How do I get the value of whether the user clicked yes or no in the next line? Is it possible that when this script fires that it will return the value and continue on the next line in the codebehind?
Upvotes: 0
Views: 4931
Reputation: 29549
Simple example here: http://jsfiddle.net/ChaseWest/W569P/
change: var script = "confirm('Would you like to close this order?')";
to: var script = confirm('Would you like to close this order?');
This saves true or false into script based on the yes or no of the confirmation popup.
Upvotes: 0
Reputation: 11342
var script = function(){
var choice = confirm('Would you like to close this order?');
if(choice){
//If the user clicks yes
}else{
//If the user clicks no
}
}
ClientScript.RegisterStartupScript(typeof(Page), "CloseOrder", script, true);
Upvotes: 1