Summary of common questions from C Response. Write

  • 2020-11-03 22:33:48
  • OfStack

This article summarizes the common problems of ES2en.Write in C# and shares them for your reference. The specific analysis is as follows:

Question 1:

After connecting Response. Redirect, Response. Write cannot be displayed, so it is directly transferred to the page of Response. Redirect.

Solutions:


Response.Write("<script languge='javascript'>alert(' Successfully changed ');
window.location.href='index.aspx'</script>");

If the script content contains variables, the solution is:


string a= Current record variable ;
500){this.resized=true;this.style.width=500;}" align=top>Response.Write("<script language='javascript'>alert('"+a+" Successfully changed '); window.location.href="/index.aspx'<";/script>");

Question 2:

If you want to pass parameters in a connection, you can use the following methods:


 string param = " Parameters passed ";
Response.Write("<script languge='javascript'>alert(' Successfully changed '); window.location.href='index.aspx?par =" + param + "'</script>");

Question 3:

If an error occurs when using Response.Redirect () or Response.Write () for URL page redirection with arguments in UpdatePanel's Ajax button.
Since Ajax is refresh-free, you need to refresh the page when using Response for parameter redirection. Under UpdatePanel, set "ControlID" of "asp: PostBackTrigger" as the specified control name, as follows:


<Triggers>
<asp:PostBackTrigger ControlID="GridView" />
</Triggers>

The redirection problem in UpdatePanel can be solved by registering client events
Jump to a page specified in 1:


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

I hope this article has been helpful in learning C# programming.


Related articles: