(转)Response.Write 后连接Response.Redirect ,则Response.Write无法显示,直接跳转入Response.Redirect 的页面...

问题一:

Response.Write 后连接Response.Redirect ,则Response.Write无法显示,直接跳转入Response.Redirect 的页面。

解决方式:

Response.Write("<script languge='javascript'>alert('成功修改'); window.location.href='index.aspx'</script>");

如果,script内容中含有变量,那么解决方法是:

string a=当前的记录变量;
None.gif500){this.resized=true;this.style.width=500;}" align=top>Response.Write(
"<script language='javascript'>alert('"+a+"成功修改'); window.location.href="/index.aspx'<";/script>");

问题二:
如果要在连接中传递参数,则可用以下方法:
 string param = "传递的参数";

Response.Write("<script languge='javascript'>alert('成功修改'); window.location.href='index.aspx?par =" + param + "'</script>");

问题三:
如果在Ajax的UpdatePanel中的按钮中用Response.Redirect()或Response.Write()进行URL带参数的页面重定向时出现错误。
由于Ajax是无刷新的,而使用Response进行带参重定向时需要刷新页面。在UpdatePanel下设置“asp: PostBackTrigger”的“ControlID”为指定的控件名称即可,如:
<Triggers>
<asp:PostBackTrigger ControlID="GridView" />
</Triggers>

可以用注册客户端事件的方法解决UpdatePanel中的重定向问题

例如:

string  scriptStr  =   " window.open('mypage.aspx?CID= "   +   this .customerInfo.Text  +   " ' ,'newwindow','height=520, width=840, top= 100, left = 100,menubar=yes ') " ;
        ScriptManager.RegisterStartupScript(
this .UpdatePanel1,  this .GetType(),  " click " , scriptStr,  true );



 

转载于:https://www.cnblogs.com/qqingmu/archive/2007/12/26/1015839.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值