0
votes

i was recently surfing the msdn for the session state management tools, i came accross viewstate, which can be used the retain the page or controls value accross the page postback, so i created a simple application, which contains a asp:textbox and asp:button now i made the EnableViewState="false" for textbox and run the page, entered some values and clicked on the button, the page postbacked but the value was retained, i thought that would be because the pages viewstate property is enabled, so i changed the EnableViewState="false" in the page directives, and run the page, still the textbox value was retained in the textbox accross the postback, can anyone tell me with small example how the does viewstate work in my scenario

2
Can we see snippets of your markup and code? - IrishChieftain

2 Answers

0
votes

ViewState can probably not be explained with a small example ;-)

I'd recommend to read this article: Truly Understanding ViewState

0
votes

The TextBox is rendered as input control, so the value is post back and set again to the TextBox.

The viewstate have a meaning on the TextBox for the other attributes that you can set it pro grammatically, or in case that you make it hidden and you like to keep the content of it.