Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...