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中的button中用Response.Redirect()或Response.Write()進行URL帶參數的頁面重定向時出現錯誤。
因為Ajax是無刷新的,而使用Response進行帶參重定向時須要刷新頁面。在UpdatePanel下設置“asp: PostBackTrigger”的“ControlID”為指定的控件名稱即可,如:
<Triggers>
<asp:PostBackTrigger ControlID="GridView" />
</Triggers>

能夠用注冊client事件的方法解決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);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM