473,735 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Page_Load method issues with Back Button

Hi,

I have a question regarding the Page_Load method and Back Button of
Internet explorer. I have created a webform. In that webform I have several
Text Boxes. Also I have two buttons. When I click on button1, it populates
the text boxes with person1 details. When I click on button2, it populates
the text box with person2 details and redirects to webform2. In webform2 if I
click on Back Button of Internet Explorer it should display details of
person2. But I am getting details of person1. I am thinking the reason for
this might be like this. When I Click on button1 in webform1, it actually
creates a new webform1. when I click on button2 on this new webform1 it is
actually not creating the new webform but just redirecting to webform2. So
when I click on back button it is displaying person1 details. Is there a
workaround for this? Please let me know.

Thnx,
Sridhar.
Jan 11 '06 #1
7 2487
Sridhar,

You're very close to figuring this out yourself. You are somewhat correct in
saying that the second button click doesn't create the web form. The web
form does get created on the server. But the server is never sending it to
the client. Instead the client receives the response.redire ct and still has
the original first form in it's cache.

To work around this problem your redirect has to occurr client side. The way
I would do it would be to populate the second instance of the form and send
it back to the client but also send back a clientside startup script (i.e.
RegisterStartup Script) that will use a javascript redirect to send the
client to the new page. This way the client will actually cache the second
version of the form. However, you may need to do something special in that
script so that the redirect doesn't occurr if the back button has been hit.

A sample javascript redirect script is here:
http://www.codeave.com/javascript/code.asp?u_log=7002
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:A8******** *************** ***********@mic rosoft.com...
Hi,

I have a question regarding the Page_Load method and Back Button of
Internet explorer. I have created a webform. In that webform I have
several
Text Boxes. Also I have two buttons. When I click on button1, it populates
the text boxes with person1 details. When I click on button2, it populates
the text box with person2 details and redirects to webform2. In webform2
if I
click on Back Button of Internet Explorer it should display details of
person2. But I am getting details of person1. I am thinking the reason for
this might be like this. When I Click on button1 in webform1, it actually
creates a new webform1. when I click on button2 on this new webform1 it is
actually not creating the new webform but just redirecting to webform2. So
when I click on back button it is displaying person1 details. Is there a
workaround for this? Please let me know.

Thnx,
Sridhar.

Jan 11 '06 #2
Hi Justin,

Thanks for the clarification. In fact I did use the
RegisterStartup Script to do that. But as you said I need to do something
special in that script so that the redirect doesn't occurr if the back
button has been hit. I am not knowing how to do that. Can you give me some
ideas on how to do that?

Thnx,
Sridhar.

"S. Justin Gengo" wrote:
Sridhar,

You're very close to figuring this out yourself. You are somewhat correct in
saying that the second button click doesn't create the web form. The web
form does get created on the server. But the server is never sending it to
the client. Instead the client receives the response.redire ct and still has
the original first form in it's cache.

To work around this problem your redirect has to occurr client side. The way
I would do it would be to populate the second instance of the form and send
it back to the client but also send back a clientside startup script (i.e.
RegisterStartup Script) that will use a javascript redirect to send the
client to the new page. This way the client will actually cache the second
version of the form. However, you may need to do something special in that
script so that the redirect doesn't occurr if the back button has been hit.

A sample javascript redirect script is here:
http://www.codeave.com/javascript/code.asp?u_log=7002
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:A8******** *************** ***********@mic rosoft.com...
Hi,

I have a question regarding the Page_Load method and Back Button of
Internet explorer. I have created a webform. In that webform I have
several
Text Boxes. Also I have two buttons. When I click on button1, it populates
the text boxes with person1 details. When I click on button2, it populates
the text box with person2 details and redirects to webform2. In webform2
if I
click on Back Button of Internet Explorer it should display details of
person2. But I am getting details of person1. I am thinking the reason for
this might be like this. When I Click on button1 in webform1, it actually
creates a new webform1. when I click on button2 on this new webform1 it is
actually not creating the new webform but just redirecting to webform2. So
when I click on back button it is displaying person1 details. Is there a
workaround for this? Please let me know.

Thnx,
Sridhar.


Jan 11 '06 #3
Sridhar,

Off the top of my head here's the way I think I'd try first:

Create a hidden filed on the form that can hold a value which will tell your
startup script if it should run or not. Just before the script does the
redirect set the hidden field to a different value. I believe that when the
back button is clicked the hidden field will retain the new value and may be
used to keep the script from running.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:5B******** *************** ***********@mic rosoft.com...
Hi Justin,

Thanks for the clarification. In fact I did use the
RegisterStartup Script to do that. But as you said I need to do something
special in that script so that the redirect doesn't occurr if the back
button has been hit. I am not knowing how to do that. Can you give me some
ideas on how to do that?

Thnx,
Sridhar.

"S. Justin Gengo" wrote:
Sridhar,

You're very close to figuring this out yourself. You are somewhat correct
in
saying that the second button click doesn't create the web form. The web
form does get created on the server. But the server is never sending it
to
the client. Instead the client receives the response.redire ct and still
has
the original first form in it's cache.

To work around this problem your redirect has to occurr client side. The
way
I would do it would be to populate the second instance of the form and
send
it back to the client but also send back a clientside startup script
(i.e.
RegisterStartup Script) that will use a javascript redirect to send the
client to the new page. This way the client will actually cache the
second
version of the form. However, you may need to do something special in
that
script so that the redirect doesn't occurr if the back button has been
hit.

A sample javascript redirect script is here:
http://www.codeave.com/javascript/code.asp?u_log=7002
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:A8******** *************** ***********@mic rosoft.com...
> Hi,
>
> I have a question regarding the Page_Load method and Back Button of
> Internet explorer. I have created a webform. In that webform I have
> several
> Text Boxes. Also I have two buttons. When I click on button1, it
> populates
> the text boxes with person1 details. When I click on button2, it
> populates
> the text box with person2 details and redirects to webform2. In
> webform2
> if I
> click on Back Button of Internet Explorer it should display details of
> person2. But I am getting details of person1. I am thinking the reason
> for
> this might be like this. When I Click on button1 in webform1, it
> actually
> creates a new webform1. when I click on button2 on this new webform1 it
> is
> actually not creating the new webform but just redirecting to webform2.
> So
> when I click on back button it is displaying person1 details. Is there
> a
> workaround for this? Please let me know.
>
> Thnx,
> Sridhar.


Jan 11 '06 #4
Hi Justin,

Thank you for taking time in replying back. I tried that but it is not
retaining the new value. It is going back to the past value. So again it is
redirecting it.

Thnx,
Sridhar.

"S. Justin Gengo" wrote:
Sridhar,

Off the top of my head here's the way I think I'd try first:

Create a hidden filed on the form that can hold a value which will tell your
startup script if it should run or not. Just before the script does the
redirect set the hidden field to a different value. I believe that when the
back button is clicked the hidden field will retain the new value and may be
used to keep the script from running.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:5B******** *************** ***********@mic rosoft.com...
Hi Justin,

Thanks for the clarification. In fact I did use the
RegisterStartup Script to do that. But as you said I need to do something
special in that script so that the redirect doesn't occurr if the back
button has been hit. I am not knowing how to do that. Can you give me some
ideas on how to do that?

Thnx,
Sridhar.

"S. Justin Gengo" wrote:
Sridhar,

You're very close to figuring this out yourself. You are somewhat correct
in
saying that the second button click doesn't create the web form. The web
form does get created on the server. But the server is never sending it
to
the client. Instead the client receives the response.redire ct and still
has
the original first form in it's cache.

To work around this problem your redirect has to occurr client side. The
way
I would do it would be to populate the second instance of the form and
send
it back to the client but also send back a clientside startup script
(i.e.
RegisterStartup Script) that will use a javascript redirect to send the
client to the new page. This way the client will actually cache the
second
version of the form. However, you may need to do something special in
that
script so that the redirect doesn't occurr if the back button has been
hit.

A sample javascript redirect script is here:
http://www.codeave.com/javascript/code.asp?u_log=7002
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:A8******** *************** ***********@mic rosoft.com...
> Hi,
>
> I have a question regarding the Page_Load method and Back Button of
> Internet explorer. I have created a webform. In that webform I have
> several
> Text Boxes. Also I have two buttons. When I click on button1, it
> populates
> the text boxes with person1 details. When I click on button2, it
> populates
> the text box with person2 details and redirects to webform2. In
> webform2
> if I
> click on Back Button of Internet Explorer it should display details of
> person2. But I am getting details of person1. I am thinking the reason
> for
> this might be like this. When I Click on button1 in webform1, it
> actually
> creates a new webform1. when I click on button2 on this new webform1 it
> is
> actually not creating the new webform but just redirecting to webform2.
> So
> when I click on back button it is displaying person1 details. Is there
> a
> workaround for this? Please let me know.
>
> Thnx,
> Sridhar.


Jan 11 '06 #5
when a user hits back, the browser generally fetchs the previous page from
its caches, no request is sent to the server. if the last request response
was a redirect, as it was in your case, then the redirect is done again. you
can turn of caching of your pages, which will cause the browser to resubmit
the form post, rather than fetch from the cache. this will cause the browser
to popup the dialog asking the user if they want to resubmit the form.

a better approach is design your site to be navigation friendly. in asp.net
1.0 don't overload a button like you have, either navigate, or save, but not
both. in asp.net 2.0 you can support this by posting to the new page, rather
than using redirect, then caching will work correctly.

-- bruce (sqlwork.com)

"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:A8******** *************** ***********@mic rosoft.com...
Hi,

I have a question regarding the Page_Load method and Back Button of
Internet explorer. I have created a webform. In that webform I have
several
Text Boxes. Also I have two buttons. When I click on button1, it populates
the text boxes with person1 details. When I click on button2, it populates
the text box with person2 details and redirects to webform2. In webform2
if I
click on Back Button of Internet Explorer it should display details of
person2. But I am getting details of person1. I am thinking the reason for
this might be like this. When I Click on button1 in webform1, it actually
creates a new webform1. when I click on button2 on this new webform1 it is
actually not creating the new webform but just redirecting to webform2. So
when I click on back button it is displaying person1 details. Is there a
workaround for this? Please let me know.

Thnx,
Sridhar.

Jan 11 '06 #6
Hi Bruce,

Thank you for the reply. I am using ASP.NET 1.1. I tried turning off
the cache. The problem is when the user clicks the Back Button, it says
"Warning: PAge has expired" something like that. Please click refresh. I
don't want to display that message every time the user hits the back button.
That is why I am going with this approach. If you know the workaround for
this situation please let me know.

Thnx,
Sridhar.

"Bruce Barker" wrote:
when a user hits back, the browser generally fetchs the previous page from
its caches, no request is sent to the server. if the last request response
was a redirect, as it was in your case, then the redirect is done again. you
can turn of caching of your pages, which will cause the browser to resubmit
the form post, rather than fetch from the cache. this will cause the browser
to popup the dialog asking the user if they want to resubmit the form.

a better approach is design your site to be navigation friendly. in asp.net
1.0 don't overload a button like you have, either navigate, or save, but not
both. in asp.net 2.0 you can support this by posting to the new page, rather
than using redirect, then caching will work correctly.

-- bruce (sqlwork.com)

"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:A8******** *************** ***********@mic rosoft.com...
Hi,

I have a question regarding the Page_Load method and Back Button of
Internet explorer. I have created a webform. In that webform I have
several
Text Boxes. Also I have two buttons. When I click on button1, it populates
the text boxes with person1 details. When I click on button2, it populates
the text box with person2 details and redirects to webform2. In webform2
if I
click on Back Button of Internet Explorer it should display details of
person2. But I am getting details of person1. I am thinking the reason for
this might be like this. When I Click on button1 in webform1, it actually
creates a new webform1. when I click on button2 on this new webform1 it is
actually not creating the new webform but just redirecting to webform2. So
when I click on back button it is displaying person1 details. Is there a
workaround for this? Please let me know.

Thnx,
Sridhar.


Jan 11 '06 #7
Sridhar,

Hmmmm, I was hoping the new value would be retained, but I wasn't sure...

I'll think about this and see if I can think of something... In the
short-run is there a reason not to just use panels and keep both forms on
the same page? Then there would be no redirect.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:70******** *************** ***********@mic rosoft.com...
Hi Justin,

Thank you for taking time in replying back. I tried that but it is not
retaining the new value. It is going back to the past value. So again it
is
redirecting it.

Thnx,
Sridhar.

"S. Justin Gengo" wrote:
Sridhar,

Off the top of my head here's the way I think I'd try first:

Create a hidden filed on the form that can hold a value which will tell
your
startup script if it should run or not. Just before the script does the
redirect set the hidden field to a different value. I believe that when
the
back button is clicked the hidden field will retain the new value and may
be
used to keep the script from running.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
news:5B******** *************** ***********@mic rosoft.com...
> Hi Justin,
>
> Thanks for the clarification. In fact I did use the
> RegisterStartup Script to do that. But as you said I need to do
> something
> special in that script so that the redirect doesn't occurr if the back
> button has been hit. I am not knowing how to do that. Can you give me
> some
> ideas on how to do that?
>
> Thnx,
> Sridhar.
>
> "S. Justin Gengo" wrote:
>
>> Sridhar,
>>
>> You're very close to figuring this out yourself. You are somewhat
>> correct
>> in
>> saying that the second button click doesn't create the web form. The
>> web
>> form does get created on the server. But the server is never sending
>> it
>> to
>> the client. Instead the client receives the response.redire ct and
>> still
>> has
>> the original first form in it's cache.
>>
>> To work around this problem your redirect has to occurr client side.
>> The
>> way
>> I would do it would be to populate the second instance of the form and
>> send
>> it back to the client but also send back a clientside startup script
>> (i.e.
>> RegisterStartup Script) that will use a javascript redirect to send the
>> client to the new page. This way the client will actually cache the
>> second
>> version of the form. However, you may need to do something special in
>> that
>> script so that the redirect doesn't occurr if the back button has been
>> hit.
>>
>> A sample javascript redirect script is here:
>> http://www.codeave.com/javascript/code.asp?u_log=7002
>>
>>
>> --
>> Sincerely,
>>
>> S. Justin Gengo, MCP
>> Web Developer / Programmer
>>
>> www.aboutfortunate.com
>>
>> "Out of chaos comes order."
>> Nietzsche
>> "Sridhar" <Sr*****@discus sions.microsoft .com> wrote in message
>> news:A8******** *************** ***********@mic rosoft.com...
>> > Hi,
>> >
>> > I have a question regarding the Page_Load method and Back Button
>> > of
>> > Internet explorer. I have created a webform. In that webform I have
>> > several
>> > Text Boxes. Also I have two buttons. When I click on button1, it
>> > populates
>> > the text boxes with person1 details. When I click on button2, it
>> > populates
>> > the text box with person2 details and redirects to webform2. In
>> > webform2
>> > if I
>> > click on Back Button of Internet Explorer it should display details
>> > of
>> > person2. But I am getting details of person1. I am thinking the
>> > reason
>> > for
>> > this might be like this. When I Click on button1 in webform1, it
>> > actually
>> > creates a new webform1. when I click on button2 on this new webform1
>> > it
>> > is
>> > actually not creating the new webform but just redirecting to
>> > webform2.
>> > So
>> > when I click on back button it is displaying person1 details. Is
>> > there
>> > a
>> > workaround for this? Please let me know.
>> >
>> > Thnx,
>> > Sridhar.
>>
>>
>>


Jan 11 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3364
by: Alfons Puig | last post by:
Some pages (not all the pages, but I can't observe differences) opened from javascript via window.showModalDialog() doesn't fire the codebehind Page_Load event the second (and further) time it is opened from the same window. If I change the IE configuration of the temporary internet files to check new versions every time the page is called then the event is fired. However it is not an acceptable solution. Thanks.
4
1520
by: Christian Ista | last post by:
Hello, On a page I have a button, I treat the event click of this button. Is it normal before I treat the method myButton_click I pass throught the Page_load event ? That's mean what, when I start the page ... Page_load .. normal when I click on the button Page_load again anf after myButton_click Christian,
0
1626
by: Itai | last post by:
Background: I have four Web Form pages with respective C# code behind files, all in the same project: localhost/vpath1 Page1.aspx Page2.aspx
2
2533
by: Frank Schumacher | last post by:
Hi Folks, I have a problem with the order of events fired by ASP.NET. I found many articles which explaining the lifecycle of a site, but I found none which took the event from a Control on the site into consideration. Here is what I want to do: I have a Button, which starts a new search session. When this session is started, you have several Usercontrols, which can navigate within the search session.
0
2292
by: jonelling | last post by:
I am having a problem where the page load event is not being fired for certain user controls that I load dynamically in placeholders. Here is what I'm doing in brief, with full test code supplied at the bottom. In my controlling .aspx page, in the page_init() sub, if not postback, I load two user controls and place them in placeholders. This works and a trace statement in each user control's page load handler is executed on initial...
3
8810
by: Imran Aziz | last post by:
Hello All, I have a search text and button that post data and my button handler filters the repeater control. However when the button is clicked the first time. The page_load event is being called twice, once with postback true, and second time without postback. This only happens for this button. How can I sort out this issue, any clues what to look for to get this sorted please. <p>Search Bookmarks: <asp:TextBox ID="txtSearch"...
1
6956
by: puja | last post by:
hi all, I have this .aspx page for which the Page_load event occurs twice. I found out while debugging. After searching google, I tried checking with Page.Ispostback method and also had "AutoEventWireUp" = false and also run after removing this tag from page directive but still my page_load event gets called twice. I have 3 pages called Search.asp, Processing.aspx and ConfirmSearch.aspx.
17
2840
by: Arpan | last post by:
When a Button is clicked in a Web Form in an ASPX page, the Form will post back to itself. Under such circumstances (i.e. when a Button is clicked), will the Page_Load sub execute first & then will the Click event function of the Button execute or will the Click event function of the Button execute first & then will the Page_Load sub execute? Thanks, Arpan
8
2690
by: John Austin | last post by:
I need to understand why if I add a control and use AddHandler to connect its click event, it will work in Page_Load, but not in a Button_Click. The idea is that the user types some data, presses the button, gets a list of results (each with a LinkButton) and can then press one of the link buttons to get further information. The newly added link buttons appear, but the click event added with AddHandler does not fire. A control added in...
0
9466
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9202
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8202
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6748
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6050
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4567
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2191
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.