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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

go to the previous page.

Status
Not open for further replies.

Premalm

Programmer
Mar 20, 2002
164
0
0
US
Hi Guys,

How do I go to the previous page in ASP.Net. I am not using javascript.
For eg I have an err page which I am calling from on all the pages in case of any error. So I want to implement a back button on the error page so that it goes to the page from which it was called.

Any ideas ? and no javascript

Thanks
Premal
 
Hmmm...I was going to say use the HTTP_REFERER servervariable but this will be blank if the user has been redirected to an error page.

What I think you may have to do is create a collection of previously visited pages.

There is a control at that does something very similar.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
You could use a session variable to pass the redirect information along.

Heres a senerio:
You have an error on page 'a.aspx', so you redirect the user to a the 'err.aspx' page.

'a.aspx' Page
Code:
Private Sub ErrHandler(ByVal err as Boolean)
     If err Then
          ' Set the page that errored into a session variable
          Session("PageErrored") = "a.aspx"
          Response.Redirect("err.aspx")
     End If
End Sub


'err.aspx' Page
Code:
Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
     If Not(Session("PageErrored") Is Nothing) Then
          Dim pErrd as String = Session("PageErrored")
          ' A session variable is shared within the browser, until either closed or cleared
          Session("PageErrored") = String.Empty
          Response.Redirect(pErrd)
     End If
End Sub

That should give you the ability to add a 'Back' button on your error page.

t
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top