开发者

Javascript Alert Not Displaying

Having trouble getting the javascript alert to display from my code behind.

c# - On Button Click

if (response != "")
{
    ClientScript.RegisterStartupScript(typeof(Page), "AlertPopup", "<script type='text/javascript'>alert('Day already exists, please edit the existing day');</script>");
    return; 
}

This is coming from within an UpdatePanel. I'm not sure if that makes a difference.

EDIT

Changed to this code, but still no luck:

ScriptManager.Reg开发者_JAVA百科isterStartupScript(this.Page, this.Page.GetType(), "AlertPopup", "<script type='text/javascript'>alert('Day already exists, please edit the existing day');</script>", true);

SOLUTION

It was loading too many script tags, this code fixed the issue:

ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "AlertPopup", "alert('Day already exists, please edit the existing day');", true);


Since it's coming from an UpdatePanel, try using the ScriptManager.RegisterStartupScript static method.

HTH.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜