关于Response.Write()

问题一:

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

解决方式:

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


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

string a=当前的记录变量;
500){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中的重定向问题

---------------------------------------------------------------------------

跳转到某一指定页面Response.Redirect("YxiaoLoan.aspx?Loan="+Ftype+"");  

-------------------------------------------------------------------------


Response.Write("<script languge='javascript'>window.parent.popupContent.Hide();</script>");

Response.Write("<script languge='javascript'>window.parent.grdCarToOther.PerformCallback(" + iCrdID + ");;</script>");


ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "", "alert('" + ex.Message + "');", true);

 

对没有封装提示框的程序员是个好东西

 

posted @ 2013-05-22 17:22  shenrq163  阅读(174)  评论(0编辑  收藏  举报