lidds Posted April 21, 2005 Posted April 21, 2005 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 Quote
PWNettle Posted April 21, 2005 Posted April 21, 2005 The simple response is to use javascript in a button: <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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.