views:

519

answers:

3

I have 2 pages.

.#1 page: session("X") receives value from user input (textbox), redirects to #2 page.

.#2 page: displays the value of session("X") to user, if user wants to change the value, redirects back to #1 page for editing.

.#1 page: session("X") loads into original textbox for user to change. Value from textbox is again placed into session("X"). Redirects to #2 page.

.#2 page: session("X") remains the same. WTF?

A: 

It is quite common for people to forget to do the "IsPostBack" check in their page load. If you do forget, you may well be setting the Textbox back to the original session value in the PageLoad just before the Button handler is called. That is, you may be overwriting the value the user just entered just before storing it in the session. Nine times out of ten when I get weird behavior like this it is because I forgot to check the IsPostBack!!

Mark Brittingham
This is not a postback scenario as there are 2 pages posting to eachother. Is it?
burntsugar
It is rare for ASP.NET to be used to do a *true* cross-page postback (it takes special processing that most people don't even know how to do). In ASP.NET it is almost always the case that the button handler posts back to the source page and *then* the source page redirects to the second page.
Mark Brittingham
A: 

About session variable and redirect, there is a good post on this:

Check this post out.

"Don't redirect after setting a Session variable (or do it right)"

J.W.
A: 

Looks like you havnt wrapped your .#1 page: session("X") loads into original textbox for user to change. in a !IsPostBack So after the button is clicked to change the value the page is "reloading" and the original value is getting put back into the text box. (so its changeing to itself)

Try debugging the button Click.

d1k_is