Asp.net returns the previous page, and asp.net returns the previous page.
In fact, JavaScript is mainly used to return to the previous page.
I:
In the source code of aspx in ASP.net
<Input type = "button onclick =" Javascript: window. history. go (-1); "value =" back to previous page ">
Analysis: This is an HTML control. Through an onclick event, you can call a method in javascript. This is the simplest and also applies to static pages and ASP pages.
II:
Use Reponse. write
If you have a certain understanding of ASP, then the Response. write is no stranger to this stuff. The first method is to implement it directly on an HTML page, then it is implemented in the background environment (this statement does not seem very standard, huh, huh)
Response. write ("<script language = javascript> history. go (-2); </script>)
<A href = "#" onclick = "javascript: history. back ();"> return to the previous page </a>
Here we will use the-2 value. I personally think it is like this: Because in asp.net, when you press a button, the page will be implemented. because of postback, the page is actually refreshed twice, and we want it for the first time, so it is ......
III:
Use Response. Redirect () or server. transfer ()
Add in page_load
If (! IsPostBack)
ViewState ["retu"] = Request. UrlReferrer. ToString ();
In the return button event
Response. Redirect (ViewState ["retu"]. ToString ());
Or Server. Transfer (ViewState ["retu"]. ToString ());
IV:
Very few people use this method, but I tried it and it was quite good.
In The onClick event of the button, enter
This. RegisterClientScriptBlock ("e", "<script language = javascript> history. go (-2); </script> ");
Returns to the previous page.
V:
<A href = <% = request. servervariable ("http_Referre) %>
<Asp: image id = "imageback" visible = true "imagurl =" Previous Page "runat =" server "/> </a>
VI:
Response. Write ("<script> alert ('prompt information'); history. back () </script> ");
Response. Write ("<script> alert ('prompt information'); top. location. href = '" + PageURL + "' </script> ")
Response. Write ("<script> alert ('prompt information'); window. location. href = '" + PageURL + "' </script> ");
Response. Write ("<script> alert ('prompt information'); window. location = window. location; </script> ");
Use Javascript to implement and use Response. redirect () is a little different. If you want to retain the data you entered when using a daily form, you need to use history. go (); you can use reponse. redirect.