Inside what the TexBox value is posted back? ViewState or post back data?
Posted
by burak ozdogan
on Stack Overflow
See other posts from Stack Overflow
or by burak ozdogan
Published on 2009-12-03T15:32:35Z
Indexed on
2010/03/28
11:03 UTC
Read the original article
Hit count: 356
In one article I was reading on ViewState, I saw a sentence saying that I should not fall into a mistake to believe that the value of a TextBox is stored in ViewState; it is stored in PostBack data.
From here what I understand is when I post back a web form, the input controls values are stored in HTTP Request body. Not in the Viewstate. But as far as I know ViewState values are stored in an hidden field called __VIEWSTATE anyway.
Then does it mean that __VIEVSTATE value is not posted in HTTP POST Request body as a postback data? Sounds nonesense to me.
In another words, basically if I say the ViewState mechanism for such scenerio works like this, am I seeing it right or skipping something:
You enter a value on an empty TextBox and submit the page
The value of text box is posted back inside POST HTTP Request body. Nothing inside __VIEWSTATE at this point from the TextBox
On the server side, the TextBox is created with the default value on OnInit method of the page
The TrackChange property of ViewState is set to true.
The posted back data of TextBox is loaded. Because it is different than the TextBox defalut value(because the user entered something), the ViewState of this text box is marked as DIRTY.
The new value of the textbox is written into __VIEWSTATE hidden field
From now on __VIEWSTATE hiddenfeild contains the last given value of the TextBox
The page is sent to the user's browser having the __VIEWSTATE hidden field. But this time containing the last value entered by user which will be ready to be rendered
Thanks guys!
burak ozdogan
© Stack Overflow or respective owner