Yajuvendra Vant
Yajuvendra Vant

Reputation: 1127

Go back to the previous page on click of custom Back Button

I am using an image button and on click of it i want to go to visited page. Now i am using - Response.Redirect(Request.UrlReferrer.ToString()), It is going to previous page, but when i am in a page of some user details where the link is looks like - users.aspx?userid=25 and i visit some other page and click back(image button) i want to see the same userdetail page. How to track that. Please Guide.

Upvotes: 2

Views: 12029

Answers (2)

Jason Evans
Jason Evans

Reputation: 29186

I would recommend using the Session object to store the url e.g.

Session("PreviousPage") = Request.Url.AbsolutePath // Or whatever....

You can then make use of the above in other pages to set the back button's url.

EDIT:

In response to your comment, are 100% sure you're saving the current url before moving to the next page?

Protected Sub btnNextPage()

    Session("PreviousPage") = Request.Url.AbsolutePath // Or whatever....
    Response.Redirect("nextpage.aspx")

End Sub

Upvotes: 0

stevemegson
stevemegson

Reputation: 12093

Do you want your custom back button to always take the user to the same page as the browser's normal back button will? If so, you can use javascript to do that with something like

myBackButton.OnClientClick = "window.history.go(-1);return false;";

Upvotes: 3

Related Questions