我有一个页面,它接受用户的输入,然后通过单击按钮处理他的请求。 在此按钮单击事件中,我需要验证他输入的输入,并在某些条件下显示确认对话框。 如果他单击"is",那么我需要执行进一步的操作,否则返回。
我尝试过使用
Page.ClientScript.RegisterStartupScript(this.GetType(), Constants.OpenConfirm, "confirm('Data Already Exists, do you Wish to Overwrite the existing record?')", true);
但无论我单击"is"还是“否”,它都会执行进一步的操作。
已尝试使用从服务器端调用 JavaScript 方法,但这也行不通。
最佳答案
您需要处理确认调用的结果。所以脚本参数必须是这样的:
if(!confirm('Data Already Exists, do you Wish to Overwrite the existing record?')) return false;
关于javascript - 服务器端的 ASP.NET 确认对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19399896/