
Caching Page Output | 53
Web Forms
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
the name itself implies, ViewState preserves the state associated with a particular
view of a page. It is used by the noninput controls (such as Label and DataGrid)
to store their ambient state across requests. Thus, when a page is posted back to
the server, and the result of the postback is rendered to the browser, controls such
as textboxes and listboxes will automatically retain their state, unless the control’s
EnableViewState property has been set to
False or the state of the control was
modified programmatically on the server.
Only base properties are persisted in the ViewState. Any change in
these properties before rendering the page will be persisted.
If your page is not posted back to itself, you can set the property EnableViewState
to
False at the page level (via the @ Page directive) to avoid the extra processing
and storage space required for maintaining ViewState. You can also disable/
enable view state on a per control basis.
Caching Page Output
Another new feature of ASP.NET that should not be overlooked is its support for
caching—in particular, output caching. Output caching provides the ability to
have the rendered output of a page cached for a specified duration simply and
easily. By caching the rendered output in memory, subsequent requests ...