Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Improved Navigation Techniques

Status
Not open for further replies.

Mike555

Technical User
Feb 21, 2003
1,200
US
In my application I have a built-in "Back" button at the top of every webform, and I have instructed users to use this "Back" button instead of the IE Back button for obvious reasons.

My back button uses a Response.Redirect call to take the user back to the previous page

My problem is... Since none of my webforms have 1 single entry point, In order to determine where the user came from, I need to pass in an extra variable ("BackTo") into each webform. This extra variable contains the name of the previous webform where the user arrived from. The Back button then sends the user back to that page.

Response.Redirect(Request.QueryString("BackTo"))

Is there an easier way to do this? I have that unsightly feeling that tells me this should be much easier than I'm making it. Thanks.

Regards,
Mike

"Don’t get suckered in by the comments – they can be terribly misleading. Debug
only code. – Dave Storer."
 
Hi,

Not necessarily an easier way, but one where the URL is not exposed in the querystring, in case this is an issue.

In the page load event,

If ( !IsPostBack ) {
ViewState["UrlReferrer"] = Request.UrlReferrer.ToString();
}

in the appropriate event, redirect to the value contained in the viewstate variable.

HTH

amit
 
akohli,

I see that this method works when a page is opened via a URL but does not work when, for example, a page is opened via a Request.Redirect("pagename"). Is it possible to capture the previous page when Request.Redirect is used? Thanks.

--
Regards,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top