我有一些看起来像这样的代码,都在代码隐藏中......
var script = "confirm('Would you like to close this order?')";
ClientScript.RegisterStartupScript(typeof(Page), "CloseOrder", script, true);
如何获取用户是否在下一行单击是或否的值?是否有可能当此脚本触发时,它会返回该值并在代码隐藏的下一行继续?
我有一些看起来像这样的代码,都在代码隐藏中......
var script = "confirm('Would you like to close this order?')";
ClientScript.RegisterStartupScript(typeof(Page), "CloseOrder", script, true);
如何获取用户是否在下一行单击是或否的值?是否有可能当此脚本触发时,它会返回该值并在代码隐藏的下一行继续?
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);
这里的简单示例:http: //jsfiddle.net/ChaseWest/W569P/
改变:var script = "confirm('Would you like to close this order?')";
至:var script = confirm('Would you like to close this order?');
这将根据确认弹出框的是或否将真或假保存到脚本中。