In fact, to achieve the function of returning to the previous page, the main thing is to use JavaScript.
One:
In the source code of the ASP.
<input type= "button onclick=" Javascript:window.history.go (-1); " Value= "Back to Prev" >
Analysis: This is the use of HTML control, through an onclick event, called a method in JavaScript can be. This is the simplest, also applicable to static pages, ASP pages and so on.
Two:
Using Reponse.write
If you have a certain understanding of ASP, then the Response.Write this east will not be unfamiliar, method one is directly have HTML page implementation, then this is in the background environment implementation (This statement seems not very standard, hehe)
Response.Write ("<script language=javascript>history.go ( -2);</script>)
<a href= "#" onclick= "Javascript:history.back ();" > Return to Previous page </a>
This is going to take the value of-2, I personally think it is: because in the ASP. NET page, when you press a button, because the page will be implemented Page.postback, actually in this is the refresh of the page two times, we want the first time, so it ......
Three:
Using Response.Redirect () or Server.Transfer ()
Join in the 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 ());
Four:
This method is estimated to be very rare, but I've tried it and it's pretty good.
Enter in the OnClick event of the button
This. RegisterClientScriptBlock ("E", "<script language=javascript>history.go ( -2);</script>");
Can go back to the previous page
Five:
<a href=<%=request.servervariable ("Http_referre)%>
<asp:image id= "Imageback" visible = True "imagurl=" previous page "runat=" Server "/></a>
Six:
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 (' hint information ');window.location=window.location;</script>");
Using JavaScript to achieve with the Response.Redirect () to achieve a little difference, if you are using the day form to keep the data you fill, it is necessary to use history.go (); If you simply return without doing anything, You can use Reponse.redirect ().