我的警報不會彈出。當我調試這個具有斷點,該行執行爲什麼我的警報不會彈出? Asp.net C#
Response.Write("<script>alert('" + " We don't seem to have this user registered. Please try again " + "') ; location.href='Login.aspx'</script>");
我的警報不會彈出。當我調試這個具有斷點,該行執行爲什麼我的警報不會彈出? Asp.net C#
Response.Write("<script>alert('" + " We don't seem to have this user registered. Please try again " + "') ; location.href='Login.aspx'</script>");
的不進行轉義需求。
Response.Write("<script>alert('" + " We don\\'t seem to have this user registered. Please try again " + "') ; location.href='Login.aspx'</script>");
應該現在彈出:
這可以如下完成。
參見下面的代碼示例,以獲得警報:
代碼背後:
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看一看有關更多信息,
您也可以試試這個..
System.Web.UI.ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Your Message.');", true);