Method to jump to the previous page (where to go back to where)

Source: Internet
Author: User

Solution 1: javascript scheme: (if this scheme is used on the server control, the jump cannot be implemented, because the server control will send back once before the jump, and the value of document. referrer is changed)

Add a js method to the image buttonGopre ()

JSCode:

<SCRIPT type = "text/JavaScript">
Function gopre (){
Window. Location. href = Document. referrer; // use document. referrer
}

</SCRIPT>

Solution 2: Asp.net background processing solution: (I am using the imagebutton Control)

<Asp: imagebutton id = "imgbtncancel" runat = "server" imageurl = "images/login_07.gif"
Onclick = "imgbtncancel_click"/>

Step 1: Obtain request. urlreferrer in the page_load method and save it in viewstate.
If (request. urlreferrer! = NULL)
{
Viewstate ["urlpre"] = request. urlreferrer;
}

Step 2: Set button click eventsOnclick

Protected void imgbtncancel_click (Object sender, imageclickeventargs E)
{
Response. Redirect (viewstate ["urlpre"]. tostring ());
}

conclusion: the above two methods can be used to redirect back to the previous page. To reduce the pressure on the server, client redirection is generally preferred, that is, the JS solution.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.