Creating a back button.

mike55

Contributor
Joined
Mar 26, 2004
Messages
727
Location
Ireland
Hi,

I have an error page for my site, this page simple displays the error message and it contains a back button that when clicked should redirect the user back to the previous page.

The get this back button operational, i have tried the following:
Code:
'Add the following to the page load event.
Me.btnBack.Attributes.Add("onClick", "javascript:history.go(-1);")

and
Code:
'Add the following to the page load event.
If Not Page.IsPostBack Then
  ViewState("ReferrerUrl") = Request.UrlReferrer.ToString()
End If

and add the following to the click event.
Response.Redirect(ViewState("ReferrerUrl").ToString())

None seem to work, any suggestions on what to do?

Mike55
 
Me.btnBack.Attributes.Add("onClick", "javascript:history.back();")


Although I don't see why this would work if the history.go(-1) didn't.
 
Alternatively as the error page initially loads you can store the url referrer in view state and then when they click the button direct them to what is in the view state for the previously saved url reffer.
 
Back
Top