无法从我后面的代码中显示 javascript 警报。
c# - 点击按钮
if (response != "")
{
ClientScript.RegisterStartupScript(typeof(Page), "AlertPopup", "<script type='text/javascript'>alert('Day already exists, please edit the existing day');</script>");
return;
}
这来自 UpdatePanel。我不确定这是否有所作为。
编辑
改成这段代码,还是不行:
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "AlertPopup", "<script type='text/javascript'>alert('Day already exists, please edit the existing day');</script>", true);
解决方案
它加载了太多的脚本标签,这段代码解决了这个问题:
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "AlertPopup", "alert('Day already exists, please edit the existing day');", true);
最佳答案
由于它来自 UpdatePanel,请尝试使用 ScriptManager.RegisterStartupScript
静态方法。
HTH.
关于c# - Javascript 警报不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6227743/