我想从服务器端在 asp.net 中显示确认框:
我想从服务器端调用它,因为我必须从服务器端获取客户消息。我正在使用下面的代码
string str = "Are you sure, you want to Approve this Record?";
ClientScript.RegisterStartupScript(typeof(Page), "Popup", "return confirm('" + str + "');",true);
// More code ....
现在它显示弹出窗口,无论我点击什么,无论是“确定”还是“取消”,我的代码都在执行。
请告诉我当用户在确认框中选择“取消”时如何限制代码执行。
最佳答案
检查一下:
代码隐藏:
string str = "Are you sure, you want to Approve this Record?";
this.ClientScript.RegisterStartupScript(typeof(Page), "Popup", "ConfirmApproval('" + str + "');", true);
ASPX:
function ConfirmApproval(objMsg)
{
if(confirm(objMsg))
{
alert("execute code.");
return true;
}
else
return false;
}
关于asp.net - asp.net 中服务器端的确认框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5114607/