M
mivhaelveloz
I thought I had a good grip on viewstate handling, but am suprised by a
small test:
In my aspx file I have a PlaceHolder control and a button for posting
back.
Dynamically in Page_Load I create a TextBox, and add it as a control of
PlaceHolder.
I do this regardless of whether IsPostBack is true or not, to insure
the control always exists on the page.
My expectation would be that any user entered information in the
TextBox would not be available across postbacks because I am not
creating it until Page_Load, which supposedly occurs *after* controls
have loaded their viewstate and processed any postback data.
But, surprise! The information I enter into the text box is being
acquired by it somehow, as I see it show up in the test box after
clicking the button, which causes a postback.
How can my textbox be getting the user supplied data if it's created
*after* the postback data has already been processed??
... To expand the test a bit, I also modified a property of the text box
in Page_Load, but only when IsPostBack == false. In other words, I
"initialize" the TextBox's Columns property to 40. Again, my
expectation is that during postback the textbox wouldn't retain this
setting as I recreate the control after viewstate handling has occured.
But yet it retains the setting.
WHAT GIVES???????
Thanks for any insights!
small test:
In my aspx file I have a PlaceHolder control and a button for posting
back.
Dynamically in Page_Load I create a TextBox, and add it as a control of
PlaceHolder.
I do this regardless of whether IsPostBack is true or not, to insure
the control always exists on the page.
My expectation would be that any user entered information in the
TextBox would not be available across postbacks because I am not
creating it until Page_Load, which supposedly occurs *after* controls
have loaded their viewstate and processed any postback data.
But, surprise! The information I enter into the text box is being
acquired by it somehow, as I see it show up in the test box after
clicking the button, which causes a postback.
How can my textbox be getting the user supplied data if it's created
*after* the postback data has already been processed??
... To expand the test a bit, I also modified a property of the text box
in Page_Load, but only when IsPostBack == false. In other words, I
"initialize" the TextBox's Columns property to 40. Again, my
expectation is that during postback the textbox wouldn't retain this
setting as I recreate the control after viewstate handling has occured.
But yet it retains the setting.
WHAT GIVES???????
Thanks for any insights!