我想从服务器端在asp.net中显示确认框: 我想从服务器端调用它,因为我必须从服务器端获取客户消息.我使用以下代码 string str = "Are you sure, you want to Approve this Record?"; ClientScript.RegisterS
我想从服务器端调用它,因为我必须从服务器端获取客户消息.我使用以下代码
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; }