.NET equivalent to Java History.Back()

  • Thread starter Thread starter James W. Cross
  • Start date Start date
J

James W. Cross

I have a System.Web.UI.WebControls.Button on a Web Form. In the Click event
(e.g. Button1_Click) I do various things (db updates, etc.) and after all is
done I want to go the user's previous URL (just like history.back(-1)).
Specifically, I want to code this "back" right in the Button1_Click
subroutine. Is this possible? Does this make sense?
 
A couple of things here.

1. history.back(-1) is not Java. "history" is an object that is supplied
by the browser - "back" is a method of that object. You can use
history.back(-1) in JavaScript or VBScript and it will work in either
language.

2. You can't use "history.back(-1)" in server code because (as stated)
"history" is a browser object, the server doesn't know anything about it.

3. You could simply add this in your Page_Load event handler to give the
button a client-side functionality:

Button1.Attributes.Add("onClick", "history.back(-1)")

4. Why would you want to create essentially a back button on the web page,
when you could just add some text letting the user know to hit the back
button on the browser? I think this is a poor design choice.
 
Sorry I didn't give adequate background. The web app I'm developing
involves a data grid. On the grid is a button that allows the user to edit
the fields in one record. This "edit" button takes the user to another form
where he makes the changes and presses the "Finish" button. MY ULTIMATE
GOAL is to have this "Finish" button initiate the db update and return to
the previous form all in one click. Perhaps I'm thinking as a VB 6'er but
there it is. Thoughts?
 
Back
Top