I saw that __VIEWSTATE field gets rendered even though I have set the EnableViewState="false" at the page level. This field is not rendered if I remove runat="server" tag for the form element. Can somebody please explain this?
views:
980answers:
2
+1
Q:
Why does __VIEWSTATE hidden field gets rendered even when I have the EnableViewState set to false
+7
A:
The __VIEWSTATE field is also used to store control state, which is not optional. Furthermore, the information contained in the view state is used to validate the postback, if I'm not mistaken (and validation is enabled, which is the default). So as long as you have the form with runat="server", you'll have a viewstate field. However, you should notice a much smaller field size if you disable all viewstate.
Chris
2008-11-12 05:51:45
This is correct, ViewState is also used to "authenticate" a PostBack to the page.
Rob Cooper
2008-11-12 06:22:14
Yep, even if no control state is used the ViewState hidden field is rendered just for the sake of the IsPostBack property
korchev
2008-11-13 22:42:34