我的提醒不会弹出。当我使用断点调试它时,执行此行
Response.Write("<script>alert('" + " We don't seem to have this user registered. Please try again " + "') ; location.href='Login.aspx'</script>");
答案 0 :(得分:3)
不 需要转义。
这可以按如下方式完成:
Response.Write("<script>alert('" + " We don\\'t seem to have this user registered. Please try again " + "') ; location.href='Login.aspx'</script>");
现在应该弹出。
答案 1 :(得分:0)
请参阅以下代码示例以获取警报:
代码背后:
protected void Page_Load(object sender, EventArgs e)
{
System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "abc", "abc();", true);
}
JavaScript:
function abc(message) {
alert(message + ", I am an alert box!");
}
有关详细信息,请查看My Answer
答案 2 :(得分:0)
你也可以尝试一下..
System.Web.UI.ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Your Message.');", true);