0

我有一些看起来像这样的代码,都在代码隐藏中......

var script = "confirm('Would you like to close this order?')";
ClientScript.RegisterStartupScript(typeof(Page), "CloseOrder", script, true);

如何获取用户是否在下一行单击是或否的值?是否有可能当此脚本触发时,它会返回该值并在代码隐藏的下一行继续?

4

2 回答 2

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);
于 2012-05-07T23:30:32.200 回答
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?');

这将根据确认弹出框的是或否将真或假保存到脚本中。

于 2012-05-07T23:30:53.040 回答