Emad - Developer
Emad - Developer

Reputation: 197

Back Button with the Same Session Var in previous page

I have a button (Back) in destination Page like this :

localhost:22211/Departments/Departments.aspx

The Back on Click should take me back to the previous page with

localhost:22211/School/School.aspx?SId=122

How can I use

Response.Redirect(" //? ");

Upvotes: 1

Views: 664

Answers (2)

gbs
gbs

Reputation: 7276

How you are navigating to that destination page? i.e. Redirect or a postback linkbutton? You can set the PostbackUrl of the back button like:

if (!IsPostBack)
{
   if (PreviousPage != null)
   {
      btnBack.PostBackUrl = PreviousPage.AppRelativeVirtualPath;
   }
}

//Note: PreviousPage won't have value if you are doing redirect from your School page.

OR else you will have to store that url into Session and get that on destination page and set the Back url.

Upvotes: 0

MPelletier
MPelletier

Reputation: 16697

One way you could do this is:

Response.Redirect(Request.UrlReferrer);

EDIT: I don't have VS open right now. Could be Request.UrlReferrer.ToString()

Upvotes: 0

Related Questions