|
You can disable a control's view state if the control does not contain any dynamic data, its value is
hard-coded, or its value is assigned on every page request and you're not handling its events.
A good example of a big consumer of view state is .NET’s DataGrid control. It is desirable to disable
view state for a page if the page does not post back. However, if the DataGrid has sorting or paging enabled,
then enabling view state is desirable.
When you complete a web page, review the controls in the page and consider what information is being
passed in the view state and whether you really need all that information to be maintained. To optimize
web page size, consider disabling view state in these cases:
- When a page does not postback to itself
- When there are no dynamically set control properties
- When the dynamic properties are set with each request of the page
|