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?
>