October 2010
Intermediate to advanced
1920 pages
73h 55m
English
You can use the ViewState property of the Control or Page class to add values to View State. The ViewState property exposes a dictionary of key and value pairs. For example, the following statement adds the string Hello World! to View State:
ViewState["message"] = "Hello World!"
Technically, you can add an instance of any serializable class to View State. In practice, however, you should add only simple values to View State, such as Strings, DateTimes, and Integers. Remember that anything that you add to View State must be added to the hidden __VIEWSTATE form field. If this field gets too big, it can have a significant impact on your page’s performance.
The control in Listing 36.12 has two properties: Text and ViewStateText ...