Home All Groups Group Topic Archive Search About

Creating a "Back" button in VB.Net/ASP.Net

Author
23 May 2006 10:05 PM
Coleen
Yes, I know why would I want to create a back button when there is one on
the browser?  Because that's what the users want!  they want a "Previous"
button that they can click from any web page in our application that will do
the exact same thing as the Back button in the browser.  Can anyone give me
any suggestions on how to do this using VB .Net?  I have Googled for "Create
Back Button" and found stuff in JavaScript and HTML but nothing in VB .Net.
Can this be done as simply as doing a response.redirect?  Any help would be
appreciated.

Coleen

Author
23 May 2006 11:21 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Coleen" <coleenhol***@yahoo.com> schrieb:
> Yes, I know why would I want to create a back button when there is one on
> the browser?  Because that's what the users want!  they want a "Previous"
> button that they can click from any web page in our application that will
> do
> the exact same thing as the Back button in the browser.  Can anyone give
> me
> any suggestions on how to do this using VB .Net?  I have Googled for
> "Create
> Back Button" and found stuff in JavaScript and HTML but nothing in VB
> .Net.
> Can this be done as simply as doing a response.redirect?  Any help would
> be
> appreciated.

As the action takes place on the client (as does pressing the browser's
"Back" button) you may want to use client-side JavaScript.  Solutions can be
found on the Web.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
23 May 2006 11:53 PM
Coleen
Yes, I know I can use JavaScript, thanks.  I was trying to find out if there
is a way to do this using VB.Net?  I have been reading all the help files
and searching on-line but can't find anything to accomplish this in VB .Net.
Is this not supported by .Net?  Why is it that things that should be very
simple are so convoluted in .Net?

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:Oupxe%23rfGHA.764@TK2MSFTNGP05.phx.gbl...
> "Coleen" <coleenhol***@yahoo.com> schrieb:
> > Yes, I know why would I want to create a back button when there is one
on
> > the browser?  Because that's what the users want!  they want a
"Previous"
> > button that they can click from any web page in our application that
will
> > do
> > the exact same thing as the Back button in the browser.  Can anyone give
> > me
> > any suggestions on how to do this using VB .Net?  I have Googled for
> > "Create
> > Back Button" and found stuff in JavaScript and HTML but nothing in VB
> > .Net.
> > Can this be done as simply as doing a response.redirect?  Any help would
> > be
> > appreciated.
>
> As the action takes place on the client (as does pressing the browser's
> "Back" button) you may want to use client-side JavaScript.  Solutions can
be
> found on the Web.
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://classicvb.org/petition/>
>
Author
24 May 2006 1:56 AM
Bob Lehmann
>> Is this not supported by .Net?

Why would it be? .Net runs on the server, and you are trying to perform a
client action.

>> Why is it that things that should be very simple are so convoluted in
..Net?

What makes you think it's simple? Is because you think simply?

Or is it because you are trying so hard to *make* it not simple?

Why do you want to go back to the server to perform an action that is
handled more simply, and natively on the client?

What is convoluted about it?

Of course, if you insist on going back to the server, I guess you could
store the previous page in a session variable, post back to the server, read
the variable, and redirect to that page.

But, that would be not simple, and also very convoluted. Oh, yeah - and
stupid.

Bob Lehmann

Show quoteHide quote
"Coleen" <coleenhol***@yahoo.com> wrote in message
news:%23Lxi0QsfGHA.2172@TK2MSFTNGP04.phx.gbl...
> Yes, I know I can use JavaScript, thanks.  I was trying to find out if
there
> is a way to do this using VB.Net?  I have been reading all the help files
> and searching on-line but can't find anything to accomplish this in VB
..Net.
> Is this not supported by .Net?  Why is it that things that should be very
> simple are so convoluted in .Net?
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> news:Oupxe%23rfGHA.764@TK2MSFTNGP05.phx.gbl...
> > "Coleen" <coleenhol***@yahoo.com> schrieb:
> > > Yes, I know why would I want to create a back button when there is one
> on
> > > the browser?  Because that's what the users want!  they want a
> "Previous"
> > > button that they can click from any web page in our application that
> will
> > > do
> > > the exact same thing as the Back button in the browser.  Can anyone
give
> > > me
> > > any suggestions on how to do this using VB .Net?  I have Googled for
> > > "Create
> > > Back Button" and found stuff in JavaScript and HTML but nothing in VB
> > > .Net.
> > > Can this be done as simply as doing a response.redirect?  Any help
would
> > > be
> > > appreciated.
> >
> > As the action takes place on the client (as does pressing the browser's
> > "Back" button) you may want to use client-side JavaScript.  Solutions
can
> be
> > found on the Web.
> >
> > --
> >  M S   Herfried K. Wagner
> > M V P  <URL:http://dotnet.mvps.org/>
> >  V B   <URL:http://classicvb.org/petition/>
> >
>
>
Author
24 May 2006 3:15 PM
Coleen
Thanks for your insults - I mean input!

Show quoteHide quote
"Bob Lehmann" <nospam@dontbotherme.zzz> wrote in message
news:u%23MSNUtfGHA.1456@TK2MSFTNGP04.phx.gbl...
> >> Is this not supported by .Net?
>
> Why would it be? .Net runs on the server, and you are trying to perform a
> client action.
>
> >> Why is it that things that should be very simple are so convoluted in
> .Net?
>
> What makes you think it's simple? Is because you think simply?
>
> Or is it because you are trying so hard to *make* it not simple?
>
> Why do you want to go back to the server to perform an action that is
> handled more simply, and natively on the client?
>
> What is convoluted about it?
>
> Of course, if you insist on going back to the server, I guess you could
> store the previous page in a session variable, post back to the server,
read
> the variable, and redirect to that page.
>
> But, that would be not simple, and also very convoluted. Oh, yeah - and
> stupid.
>
> Bob Lehmann
>
> "Coleen" <coleenhol***@yahoo.com> wrote in message
> news:%23Lxi0QsfGHA.2172@TK2MSFTNGP04.phx.gbl...
> > Yes, I know I can use JavaScript, thanks.  I was trying to find out if
> there
> > is a way to do this using VB.Net?  I have been reading all the help
files
> > and searching on-line but can't find anything to accomplish this in VB
> .Net.
> > Is this not supported by .Net?  Why is it that things that should be
very
> > simple are so convoluted in .Net?
> >
> > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> > news:Oupxe%23rfGHA.764@TK2MSFTNGP05.phx.gbl...
> > > "Coleen" <coleenhol***@yahoo.com> schrieb:
> > > > Yes, I know why would I want to create a back button when there is
one
> > on
> > > > the browser?  Because that's what the users want!  they want a
> > "Previous"
> > > > button that they can click from any web page in our application that
> > will
> > > > do
> > > > the exact same thing as the Back button in the browser.  Can anyone
> give
> > > > me
> > > > any suggestions on how to do this using VB .Net?  I have Googled for
> > > > "Create
> > > > Back Button" and found stuff in JavaScript and HTML but nothing in
VB
> > > > .Net.
> > > > Can this be done as simply as doing a response.redirect?  Any help
> would
> > > > be
> > > > appreciated.
> > >
> > > As the action takes place on the client (as does pressing the
browser's
> > > "Back" button) you may want to use client-side JavaScript.  Solutions
> can
> > be
> > > found on the Web.
> > >
> > > --
> > >  M S   Herfried K. Wagner
> > > M V P  <URL:http://dotnet.mvps.org/>
> > >  V B   <URL:http://classicvb.org/petition/>
> > >
> >
> >
>
>
Author
24 May 2006 3:45 PM
Coleen
Sorry  I couldn't Resist :-)

The plain "simple" truth is that I don't know JavaScript - and honestly do
NOT know that much about what calls the server and what calls the client so
I did not realize that Javascript does not call the server while .Net
does...so my remarks were in ignorance of .Net's capabilities not meant to
belittle .Net - only that I thought this should be a simple thing to do.

The problem I am having is that since I do not Know JavaScript, the code
that I have found on-line to do this simple (yes the CODE IS simple in
JavaScript and even in HTML!) but I am using a User Control that has
multiple buttons and I put the code for the Back button in the User Control
VB code-behind:

btn_prev.Attributes.Add("onclick", "javascript:history.go(-1);")
btn_prev.Attributes.Add("onclick", "javascript:history.back();")

Neither one of these works, and since I don't know JavaScript I do NOT know
how to get this to work!

If you have any suggestions I would appreciate them.

Coleen

Show quoteHide quote
"Coleen" <coleenhol***@yahoo.com> wrote in message
news:e9ujOU0fGHA.4900@TK2MSFTNGP02.phx.gbl...
> Thanks for your insults - I mean input!
>
> "Bob Lehmann" <nospam@dontbotherme.zzz> wrote in message
> news:u%23MSNUtfGHA.1456@TK2MSFTNGP04.phx.gbl...
> > >> Is this not supported by .Net?
> >
> > Why would it be? .Net runs on the server, and you are trying to perform
a
> > client action.
> >
> > >> Why is it that things that should be very simple are so convoluted in
> > .Net?
> >
> > What makes you think it's simple? Is because you think simply?
> >
> > Or is it because you are trying so hard to *make* it not simple?
> >
> > Why do you want to go back to the server to perform an action that is
> > handled more simply, and natively on the client?
> >
> > What is convoluted about it?
> >
> > Of course, if you insist on going back to the server, I guess you could
> > store the previous page in a session variable, post back to the server,
> read
> > the variable, and redirect to that page.
> >
> > But, that would be not simple, and also very convoluted. Oh, yeah - and
> > stupid.
> >
> > Bob Lehmann
> >
> > "Coleen" <coleenhol***@yahoo.com> wrote in message
> > news:%23Lxi0QsfGHA.2172@TK2MSFTNGP04.phx.gbl...
> > > Yes, I know I can use JavaScript, thanks.  I was trying to find out if
> > there
> > > is a way to do this using VB.Net?  I have been reading all the help
> files
> > > and searching on-line but can't find anything to accomplish this in VB
> > .Net.
> > > Is this not supported by .Net?  Why is it that things that should be
> very
> > > simple are so convoluted in .Net?
> > >
> > > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> > > news:Oupxe%23rfGHA.764@TK2MSFTNGP05.phx.gbl...
> > > > "Coleen" <coleenhol***@yahoo.com> schrieb:
> > > > > Yes, I know why would I want to create a back button when there is
> one
> > > on
> > > > > the browser?  Because that's what the users want!  they want a
> > > "Previous"
> > > > > button that they can click from any web page in our application
that
> > > will
> > > > > do
> > > > > the exact same thing as the Back button in the browser.  Can
anyone
> > give
> > > > > me
> > > > > any suggestions on how to do this using VB .Net?  I have Googled
for
> > > > > "Create
> > > > > Back Button" and found stuff in JavaScript and HTML but nothing in
> VB
> > > > > .Net.
> > > > > Can this be done as simply as doing a response.redirect?  Any help
> > would
> > > > > be
> > > > > appreciated.
> > > >
> > > > As the action takes place on the client (as does pressing the
> browser's
> > > > "Back" button) you may want to use client-side JavaScript.
Solutions
> > can
> > > be
> > > > found on the Web.
> > > >
> > > > --
> > > >  M S   Herfried K. Wagner
> > > > M V P  <URL:http://dotnet.mvps.org/>
> > > >  V B   <URL:http://classicvb.org/petition/>
> > > >
> > >
> > >
> >
> >
>
>
Author
24 May 2006 5:57 PM
aaron.kempf@gmail.com
i think that this would be complex in vb.net; i mean-- you would need
to encode an undo functionality to everything you.

perhaps starting a transaction and not commiting it would be the way to
go?

are you building data entry apps??

-Aaron
Author
24 May 2006 7:11 PM
Coleen
Yes.  The app is an on-line entry for users and we have created a "Footer"
user control that has all the buttons for Back, Submit, Next , Add, Clear or
Update the current page.  Some buttons will have slightly different
functions from page to page, but buttons such as the Back, Next, and Submit
will always do the same thing.  So I am trying to set up the code to do the
Back and next buttons in the User Control.  The code I showed before for the
JavaScript doesn't work, so since I'm not a JavaScript programmer I don't
know how to troubleshoot it.  If you have any suggestions on how to embed a
JavaScript function in a VB/ASCX User Control, I would greatly appreciate
any help.

Thanks :-)

Coleen


<aaron.ke***@gmail.com> wrote in message
Show quoteHide quote
news:1148493471.895833.277870@j33g2000cwa.googlegroups.com...
> i think that this would be complex in vb.net; i mean-- you would need
> to encode an undo functionality to everything you.
>
> perhaps starting a transaction and not commiting it would be the way to
> go?
>
> are you building data entry apps??
>
> -Aaron
>
Author
24 May 2006 8:57 PM
Coleen
Okay - I got some help from someone who knows JavaScript here and we solved
this by putting the code:
btn_prev.Attributes.Add("onclick", "javascript: history.go(-1); return
false;")
in the Page load of the user control instead of in the Click event of the
control.  Two things here - I was not using the return false option or
spacing the JavaScript code correctly, and the code has to be in the page
load not in the Click event. Any way, this is the solution for any one else
who comes across this problem.

Coleen

Show quoteHide quote
"Coleen" <coleenhol***@yahoo.com> wrote in message
news:%23jDhfUrfGHA.3456@TK2MSFTNGP05.phx.gbl...
> Yes, I know why would I want to create a back button when there is one on
> the browser?  Because that's what the users want!  they want a "Previous"
> button that they can click from any web page in our application that will
do
> the exact same thing as the Back button in the browser.  Can anyone give
me
> any suggestions on how to do this using VB .Net?  I have Googled for
"Create
> Back Button" and found stuff in JavaScript and HTML but nothing in VB
..Net.
> Can this be done as simply as doing a response.redirect?  Any help would
be
> appreciated.
>
> Coleen
>
>