无法从我的代码后面显示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);
答案 0 :(得分:3)
由于它来自UpdatePanel,请尝试使用ScriptManager.RegisterStartupScript
静态方法。
HTH。