navigate 'back'

  • Thread starter Thread starter MattB
  • Start date Start date
M

MattB

Can anyone tell me how to make an asp.net hyperlink object just go back to
the previous page without just redirecting to the previous page? I'd like to
make this work like the browser's back button. Thanks!
 
In your page_load method add a handler to onclick event of the asp hyperlink control

myHyperLink.Attributes.Add("onclick", "Javascript: history.back();")

If all you need the link to do it so go back then you might as well use html hyperlink(<a href="..">Back</a>) with javascript

HTH
Suresh

----- MattB wrote: ----

Can anyone tell me how to make an asp.net hyperlink object just go back t
the previous page without just redirecting to the previous page? I'd like t
make this work like the browser's back button. Thanks
 
note - you will need to track the number of postbacks to the same page.

so if the user has clicked two buttons, then clicks on the back button, you
need to go back 3

myHyperLink.Attributes.Add("onclick", string.Format("Javascript:
history.back({0});",postbackCount));

you can track the postback count in a hidden field or viewstate

-- bruce (sqlwork.com)
 
set Hyperlink property navigateUrl to Javascript:history.back(1) and it wil
work without code :)
 
Back
Top