alert('弹出对话框!')") 后跟Response.Redirect("page.aspx");不能弹出对话框,直接跳转页面了 如何解?" type="hidden"/>

Response.Write("") 后跟Response.Redirect("page.aspx");不能弹出对话框,直接跳转页面了 如何解?


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>");

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM