asp.net.ph

Control.EnableViewState Property

System.Web.UI Namespace   Control Class


Sets or retrieves a value indicating whether the server control persists its view state to the requesting client.

Syntax


Inline <asp:control EnableViewState = true | false ... >
Script Control.EnableViewState [ = true | false ]

Property Value

This property accepts or returns only a boolean value: true if the server control maintains its view state; otherwise false.

This property is read/write with a default value of true.

Remarks

You must enable view state for the server control to maintain its state across HTTP requests.

A server control's view state, and the view state of any child controls it contains, is the accumulation of all its property values. In order to preserve these values across HTTP requests, ASP.NET uses an instance of the StateBag class to store the property values. The values are then passed as a variable to a hidden field when subsequent requests are processed. For more information about view state, see Web Forms State Management.

There are times when it is appropriate to disable view state, particularly to improve application performance. For example, if you are loading a database request into a server control, set this property to false. If you do not, processor time will be wasted loading view state into the server control that will only be overridden by the database query.

For information about how to enable or disable view state declaratively for an ASP.NET page, see the @ Page directive.

Example

The following example demonstrates setting the EnableViewState property to false.

<asp:datagrid id="myGrid" runat="server"
   width="95%"
   cellpadding=3
   font-size="8pt"
   headerstyle-backcolor="#bbccdd"
   headerstyle-font-bold
   enableviewstate=false />

 Show me 

See Also

Control Members   Web Forms Page Processing Stages   Web Forms State Management | @ Page Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph