Saturday, July 21, 2007

State Management : Viewstate Basics

Viewstate

In web forms, viewstate is sent by the server as a hidden variable in a form, as part of every response to the client
Stores values per control by key name, like a hashtable
Serializes and Deserializes saved data into a hidden form field on the client
Returned to the server by the client as a part of a postback as a hidden client
Viewstate data is not encrypted, only Base64 encoded
To make viewstate more secure use page attribute called EnableViewStateMac
Viewstate can be written only after init event is fired for a page request
Data can be read from anytime from Viewstate but not after page enters rendering mode
To turn-off viewstate: <%@Page EnableViewState = “false” %>


Datatypes supported by Viewstate

Strings
Integer
Boolean Values
Array Objects
ArrayList Objects
Hash Tables
Custom types

No comments: