Use the session record page address and implement the page return function

xiaoxiao2021-03-06  38

In the development process, in order to meet the requirements of the customer to implement such a function: Click on a text connection in a page to enter the C page, you can return A page after clicking the return button, and there is also the text connection in the page, click after entering C Page, return to the B page (only one return button in the C page). For this reason, I think of the use session feature, which is to jump from the c page that is jumped from which page jumps, then click the Back button. The content of the session is determined, which is determined whether to return A and a page.

First, add the code to get the page path within the two pages of A, B.

String Url = Request.currentexecutionFilePath.toString ();

/ / Get the virtual path of the current page

Session ["URL"] = URL;

Response.Redirect ("C.ASPX", TRUE;

Get the virtual path of the previous page through the session in the C page.

String Url = session ["URL"]. TOSTRING ();

Since the first half of the virtual path of AB is the same, it is actually that we will determine "a.ASPX" or "B.ASPX", so take the Split method to get the page name we want, then you can assign the name Give a label, hide this Label within the page (whether you need to use Lable to save the page name).

String [] split = url.split (new char [] {'/'});

INT n = split.length;

String pathname = split [n-1];

Label1.text = pathname;

Finally, it is determined in the response event of the return button to determine which page:

IF (label1.text == "a.aspx")

Response.Redirect ("a.aspx", true);

Else

Response.Redirect ("B.ASPX", TRUE;

转载请注明原文地址:https://www.9cbs.com/read-75906.html

New Post(0)