日期:2014-05-17  浏览次数:20352 次

为什么在后台写的弹出提示框代码无效?
代码如下:
  Response.Write("<script>alert('您目前不能登录此系统!')</script>");
  Response.Redirect("~/Login.aspx");
上面一句总是执行不了,我给它换成RegisterStartupScript或者RegisterClientScriptBlock也不行。不过将后面一句代码删除之后,还是可以弹出提示框来,谁能告诉我这是为什么?怎么写才可以弹出提示框,然后跳转到另一个页面?

------解决方案--------------------
因为页面转向了,如下修改,注意转向路径
C# code
this.RegisterStartupScript("Awoke", "<script>alert('您目前不能登录此系统!');window.location.href='Login.aspx';</script>");

------解决方案--------------------
Response.Redirect("~/Login.aspx"); 没等到 Response.Write("<script>alert('您目前不能登录此系统!')</script>"); 就直接跳转走了
------解决方案--------------------
this.RegisterStartupScript(this.getType(),"", "alert('您目前不能登录此系统!');window.location.href='Login.aspx';",true);