D
Dwight Johnson
I have read countless posts about how people are expecting a textbox
to clear after postbacks, and they do not, and the developer is
confused. And the responses always say "well, this is the way it was
designed to work", and leave it at that. What I NEVER see is how to
get a page to do what all these people clearly WANT it to do.
Example: I have a page that creates a dropdownlist during the
InitializeComponent method, then checks the value of that dropdownlist
and proceeds to fill a textbox with data based on the value of that
dropdown in the Page_Load method. If you step thru the whole process,
the textbox Text property gets the appropriate value.
Now, the dropdownlist has AutoPostBack = true, so, when it changes,
the page is posted back, there is a new value in the dropdownlist, and
the appropriate matching text is assigned to the textbox. But when the
page appears, the textbox contains the original value, not the new
value just put there by the codebehind. Clearly not acting as one
would expect.
I understand why this happens, having read all the helpfully linked
articles about viewstate, etc, that were placed in previous similar
posts.
What I want to know is how to get it to behave the way I EXPECT it to
work. Has anyone figured that out?
to clear after postbacks, and they do not, and the developer is
confused. And the responses always say "well, this is the way it was
designed to work", and leave it at that. What I NEVER see is how to
get a page to do what all these people clearly WANT it to do.
Example: I have a page that creates a dropdownlist during the
InitializeComponent method, then checks the value of that dropdownlist
and proceeds to fill a textbox with data based on the value of that
dropdown in the Page_Load method. If you step thru the whole process,
the textbox Text property gets the appropriate value.
Now, the dropdownlist has AutoPostBack = true, so, when it changes,
the page is posted back, there is a new value in the dropdownlist, and
the appropriate matching text is assigned to the textbox. But when the
page appears, the textbox contains the original value, not the new
value just put there by the codebehind. Clearly not acting as one
would expect.
I understand why this happens, having read all the helpfully linked
articles about viewstate, etc, that were placed in previous similar
posts.
What I want to know is how to get it to behave the way I EXPECT it to
work. Has anyone figured that out?