Method One:
In the source code in ASP.net's aspx,
<input type= "button onclick=" Javascript:window.history.go (-1); " Value= "Back to previous page" >
This is the use of HTML control, through a onclick event, invoke JavaScript in a method is OK. This is the simplest, but also applies to static pages, ASP pages and so on.
Method Two:
Using Reponse.write
If you have a certain understanding of the ASP, then the Response.Write this dongdong will not be unfamiliar, method one is directly to achieve the HTML page, then this is in the background of the implementation of the environment (this argument seems not very normative, hehe)
Copy Code code as follows:
Response.Write ("<script language=javascript>history.go ( -2);</script>)
<a href= "#" onclick= "Javascript:history.back ();" > Back to Previous page </a>
Is this going to take the value of 2? I personally think this is the case: because in the ASP.net page, when you press a button, because the page will realize the page.postback, in fact, in this one is refreshed two times page, we want is the first time, so on ......
Method Three
Use Response.Redirect () or Server.Transfer ()
Join in the Page_Load
if (! IsPostBack)
viewstate["Retu"]=request.urlreferrer.tostring ();
And in the Return button event
Response.Redirect (viewstate["Retu"). ToString ());
or Server.Transfer (viewstate["Retu"). ToString ());
Analysis
Request.urlreferrer can get information about the URL that the client requested last time, we'd better make a judgment about it when we use it.
if (viewstate["Urlreferrer"]!=null)
Response.Redirect (viewstate["Urlreferrer"). ToString ();
Else
{
Response.Write ("Sorry, at present is the first page number");
It just makes it a little bit more!
}
Also note when using Request.urlreferrer:
1. If the previous page uses the Document.location method to navigate to the current page, Request.urlreferrer returns a null value
2. If there are a,b two pages, direct request a page in the browser, the Page_Load event in page A to navigate to the B page, then request.urlreferrer return empty. Because the page is not initialized in the Page_Load event, the information for the current page cannot be logged, and the information on the previous page cannot be obtained by navigating to page B
3. Clicking the Refresh button does not change the Request.urlreferrer
Method Four:
This method is estimated to be very few people, but I tried it, and it was pretty good.
In the button's onclick event, enter
This. RegisterClientScriptBlock ("E", "<script language=javascript>history.go ( -2);</script>");
You can go back to the previous page.
Method Five
Copy Code code as follows:
<a href=<%=request.servervariable ("Http_referre")%>
<asp:image id= "Imageback" visible = True "imagurl=" previous page "runat=" Server "/></a>
Method Six
Copy Code code as follows:
Response.Write ("<script>alert"); History.back () </script> ");
Response.Write ("<script>alert"); top.location.href= ' "+ pageurl +" ' </script> ")
Response.Write ("<script>alert"); window.location.href= ' "+ pageurl +" ' </script> ");
Response.Write ("<script>alert (' cue message ');window.location=window.location;</script>");
Here is also a little bit of JavaScript to achieve with the Response.Redirect () to achieve a small difference, if you are using the day form to retain the data you fill, it will be used history.go (); If you just return directly without doing anything, you can use Reponse.redirect ().