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?

Re: .NET equivalent to Java History.Back() by Scott

Scott
Thu Jan 06 18:40:49 CST 2005

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.


"James W. Cross" <crossjames@srt.com> wrote in message
news:ePNGeSE9EHA.3596@TK2MSFTNGP12.phx.gbl...
>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?
>



Re: .NET equivalent to Java History.Back() by James

James
Fri Jan 07 11:06:47 CST 2005

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?

"Scott M." <s-mar@nospam.nospam> wrote in message
news:%23yxaREF9EHA.1084@TK2MSFTNGP15.phx.gbl...
>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.
>
>
> "James W. Cross" <crossjames@srt.com> wrote in message
> news:ePNGeSE9EHA.3596@TK2MSFTNGP12.phx.gbl...
>>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?
>>
>
>