Response.Write和Response.Redirect一起用的时候就会这样,write脚本和redirect脚本不能同时使用,这样不会执行脚本,最好使用ClientScript

改进方法:

方法一:

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script language=javascript >alert('弹出对话框!');</script>");
Response.Redirect("page.aspx");

方法二:

Response.Write("<script>alert('弹出对话框!');window.location.href = 'page.aspx';</script>");

方法三:

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script language=javascript >alert('弹出对话框!');window.location.href = 'page.aspx';</script>");
04-24 13:46