开发者

Javascript Alert Not Displaying

开发者 https://www.devze.com 2023-03-10 09:33 出处:网络
Having trouble getting the javascript alert to display from my code behind. c# - On Button Click if (response != \"\")

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

精彩评论

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