脚本管理器弹出窗口不会出现

时间:2014-06-19 20:22:08

标签: c# asp.net popup

我有一个ASP.NET页面。我想点击页面上的某个按钮弹出一个弹出窗口。我使用的语法是:

ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Invalid Address!!');", true);

弹出窗口没有出现。

但是,当在同一个项目中的不同页面上尝试相同的语法时,它可以正常工作。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

尝试从

更改以下行
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Invalid Address!!');", true);

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "popup", "alert('Invalid Address!!');", true);

如果由于某种原因上述代码无效,请尝试以下代码

 ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "alert",
                            "Javascript:displayAlert('Invalid Address!!');", true);

和你的JS函数

function displayAlert(msg) {
   alert(msg);
   return false;
}
相关问题