Wednesday, March 28, 2012

Simple Beginner Question (I believe)

VS 2003, C# if the language matters.
Scenario:
Two page project, text box content on the start page is loaded into session
variables to be displayed in a greeting on the second page. Works fine the
first trip.
If upon return from the second page to the start page, the user enters new
data into the text boxes and then navigates (code in the navButton_Click
event procedure loads the session variables) to the second page, the old
data is still displayed.
Stepping through in the debugger seems to indicate that new data entry into
the text boxes does not cause the start page to be redrawn, thus the new
data shown in the interface is never transferred to the text property of the
text boxes?
Any thoughts appreciated!The start page is not "redrawn," it is created when a PostBack occurs. Are
you re-setting the Session variables prior to doing your redirect?
HTH,
Kevin Spencer
Microsoft MVP
Professional Numbskull
Hard work is a medication for which
there is no placebo.
"pvdg42" <pvdg42@.newsgroups.nospam> wrote in message
news:ugl%23vYhZGHA.1192@.TK2MSFTNGP04.phx.gbl...
> VS 2003, C# if the language matters.
> Scenario:
> Two page project, text box content on the start page is loaded into
> session variables to be displayed in a greeting on the second page. Works
> fine the first trip.
> If upon return from the second page to the start page, the user enters new
> data into the text boxes and then navigates (code in the navButton_Click
> event procedure loads the session variables) to the second page, the old
> data is still displayed.
> Stepping through in the debugger seems to indicate that new data entry
> into the text boxes does not cause the start page to be redrawn, thus the
> new data shown in the interface is never transferred to the text property
> of the text boxes?
> Any thoughts appreciated!
>
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:OWeI2$jZGHA.3960@.TK2MSFTNGP02.phx.gbl...
> The start page is not "redrawn," it is created when a PostBack occurs. Are
> you re-setting the Session variables prior to doing your redirect?
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> Professional Numbskull
> Hard work is a medication for which
> there is no placebo.
>
Yes, I believe so. The code in the click event procedure for the navigate
button is:
Session[ "name" ] = txtName.Text;
Session[ "phonenumber" ] = txtPhoneNumber.Text;
// redirect to RoadTestRegistered.aspx page
Response.Redirect( "RoadTestRegistered.aspx" );
This works fine the first time the user fills in the text boxes and
navigates to the second page. If the user then returns to the first page and
enters new information in the text boxes, the app acts as it the new entries
have been ignored when the navigate button is clicked the second time. The
old (first entries) information reappears on the second page.
How is the user returning to the first page?
HTH,
Kevin Spencer
Microsoft MVP
Professional Numbskull
Hard work is a medication for which
there is no placebo.
"pvdg42" <pvdg42@.newsgroups.nospam> wrote in message
news:%23kxIPPmZGHA.3960@.TK2MSFTNGP02.phx.gbl...
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:OWeI2$jZGHA.3960@.TK2MSFTNGP02.phx.gbl...
> Yes, I believe so. The code in the click event procedure for the navigate
> button is:
> Session[ "name" ] = txtName.Text;
> Session[ "phonenumber" ] = txtPhoneNumber.Text;
> // redirect to RoadTestRegistered.aspx page
> Response.Redirect( "RoadTestRegistered.aspx" );
> This works fine the first time the user fills in the text boxes and
> navigates to the second page. If the user then returns to the first page
> and enters new information in the text boxes, the app acts as it the new
> entries have been ignored when the navigate button is clicked the second
> time. The old (first entries) information reappears on the second page.
>
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:OFL7NWmZGHA.1204@.TK2MSFTNGP04.phx.gbl...
> How is the user returning to the first page?
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> Professional Numbskull
>
1. I appreciate you bearing with me :)
2. Via Response.Redirect()
And, I now see that if the browser back button is used instead, the new
values *do* get recognized. Looks like I need a hammer and am trying to use
a screwdriver.
Thanks very much.
Hi Pvdg42,
I agree that the client-side browser's back/forward button is the cause.
When we use back/forward button on client-side browser to navigate page, it
will used the cached item and data in client-side's browser cache, so this
may not works as expected, we can output some http header to prevent
client-side caching, e.g:
#How to prevent caching in Internet Explorer
http://support.microsoft.com/kb/234067/en-us
it provide the example on ASP pages, and ASP.NET also support this (and
provide the Response.Cache property which provide more features on cache
control).
Hope this also helps.
Regards,
Steven Cheng
Microsoft Online Community Support
========================================
==========
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
==========
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

0 comments:

Post a Comment