Button to go back...

lidds

Junior Contributor
Joined
Nov 9, 2004
Messages
210
How is it possible to make a button go back to the previous page, rather than redirecting it to the actual htm page (loses all the info put in input fields)

Cheers

Simon
 
The simple response is to use javascript in a button:

Code:
<input type="button" value="back" onclick="history.back();">

However, if you're page has been "refreshing" via numerous postbacks then you'd actually need to use:

"history.go(-x)"

(which will enable your page to truly back up to the previous page rather than backing thru all the postbacks)

where "x" is a counter you maintain in your codebehind based on how many times you've done postbacks (need to store the value between postbacks in ViewState or something). In this type of situation you'd probably want your button to be setup to runat=server so you could dynamically create the javascript "onclick" event to include the "back count".

Paul
 
Back
Top