Use session record page address and implement page return function

Source: Internet
Author: User
In the development process in order to meet customer requirements to achieve such a function: In a page, click a text connected to enter the C page, after clicking the return button can return a page, and in the B page also has the text connection, click to enter the C page, Returns the B page (there is only one return button in the C page). This thought of the use of the session function, that is, to the C page when the record is jumping from which page, and then click the Return button to the contents of the session to judge, so that the decision is to return a page or b page.
First in the A,b two pages to add the code to get the page path
String url=request.currentexecutionfilepath.tostring ();
Get the virtual path of the current page
session["URL"]=URL;
Response.Redirect ("C.aspx", true);
In the C page first through session to get the last page of the virtual path
String url=session["url"]. ToString ();
Since the first half of the virtual path of the A.B two pages is the same, in fact we just have to judge whether it is "a.aspx" or "b.aspx". So we get the name of the page we want by using the Split method, and then we can assign the name to a label, Hide the label inside the page (whether you need to use lable to save the page name in this case depends on the situation).
String[] Split=url. Split (new char[] {'/'});
int N=split. Length;
String pathname=split[n-1];
Label1.text=pathname;
Finally, in the response to the return button to determine the event, decide which page to return:
if (label1.text== "a.aspx")
Response.Redirect ("A.aspx", true);
Else
Response.Redirect ("B.aspx", true);

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.