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