Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2005

Tip: Looking for answers? Try searching our database.

.NET equivalent to Java History.Back()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
James W. Cross - 06 Jan 2005 23:09 GMT
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?
Scott M. - 07 Jan 2005 00:34 GMT
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.

>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?
James W. Cross - 07 Jan 2005 17:05 GMT
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?

>A couple of things here.
>
[quoted text clipped - 20 lines]
>>history.back(-1)). Specifically, I want to code this "back" right in the
>>Button1_Click subroutine.  Is this possible?  Does this make sense?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.