Last post Jan 24, 2014 06:57 AM by kaushalparik27
Jan 24, 2014 05:58 AM|unknowncode|LINK
I studied the about view state enable and disable option. To understand it more clearly i tried it by disable it in 'EnableViewState="false"' @ page directive.
I created two text box in the content page
and have one asp button
i just entered the value in the text box and click the button. even though i disable the viewstate i can able to see the values in text box.
Can any one clear this
Jan 24, 2014 06:51 AM|sandeepchrs|LINK
<asp:TextBox id="Textbox1" runat="server" autocomplete="off"></asp:TextBox>
Jan 24, 2014 06:57 AM|kaushalparik27|LINK
Most developers would have expected textbox controls to lose their modified values, and after page re-loading, they expect “Initial Value” being written on textboxes as we had disabled the ViewState.
The reason for this behavior is that ViewState is not responsible for storing the modified values for controls such as TextBoxes, dropdowns, CheckBoxList etc., i.e., those controls which inherit from the IPostBackDataHandler interface. After Page_Init(), there
is an event known as LoadViewState, in which the Page class loads values from the hidden__VIEWSTATE from the field for those controls (e.g., Label) whose ViewState is enabled. Then the LoadPostBackData event fires, in which the Page class loads the values
of those controls which inherit from the IPostBackDataHandler interface, (e.g., TextBox) from the HTTP POST headers.
So we conclude that controls which inherit from the IPostBackDataHandler interface will retain their values even if the ViewState has been disabled, as their values are stored in HTTP POST headers.
You might want to refer the original article of my colleague here:
Misconception Regarding ViewState in ASP.NET
hope it helps./.