Save the server control view status only when necessary

xiaoxiao2021-03-06  112

Auto View Status Management is the functionality of the server control, which allows the server control to re-fill their attribute values ​​(you do not need to write any code) on the round-trip process. However, because the view status of the server control is to and from the server in the hidden form field, this feature does have an impact on performance. You should know which case the view status will help, where it affects the performance of the page. For example, if you bind the server control to data on each round-trip process, replace the saved view status with the new value obtained from the data binding operation. In this case, the disable view status can save time.

By default, view status is enabled for all server controls. To disable the view status, set the control's EnableViewState property to false, as shown in the following DataGrid server control sample.

You can also use the @ page instruction to disable the view status of the entire page. This will be very useful when you don't return from the page to the server:

<% @ Page EnableViewState = "false"%>

Note that the enableViewState property is also supported in the @ Control instruction, which allows you to control whether you enable view status for the user control. To analyze the number of view status used by the server control, please enable the page of the Control Hierarchy table by incorporated the trace = "true" property in the @ page directive) and view the ViewState column of the Control Hierarchy table. For information on tracking and how to enable it, see ASP.NET Tracking.

转载请注明原文地址:https://www.9cbs.com/read-101646.html

New Post(0)