Understanding ViewState Management in ASP.NET

It is a tough task for developers who develop web applications for storing or preserving the various values from a page and it is also equally difficult to make them available to other pages in the application. In a standard HTML page, the server will respond to any request from the browser and the server will make available the requested data or the page to the user.

During this process a connection will be made and the HTML page will get linked with the server, and once the data or the requested page is displayed or made available to the user the established connection will be severed. And that is the reason why the HTML is considered to be a disconnected protocol.

In ASP (Active Server Pages) the developers have tried managing the information manually by ways like hidden values of input and many session dependent variables and as these activities are carried out manually, you need to be very elaborate while writing the codes for the page.

The ViewState management that comes as a built-in state of web forms in ASP.NET helps in automatically remembering and maintaining the various values of the controls that the form holds. This feature also enables the developer to make use of the values of the variables and the control information across all the pages of the form and as well in other applications.

In ViewState management the information that has been sought by the client or the user will be sent to the client along with the HTTP (Hypertext Transfer Protocol) and this particular process will save your server from memory overloads, as the details or information need not be stored in the server for each and every request.

With all the favourable advantages mentioned above, you do have one or two disadvantages when it comes to ViewState management is ASP.NET. The disadvantage is that for each request from the client, the ViewState management will send a 4KB size extra information to the client and this particular act makes the server process more when ViewState management is implemented. Hence, it is advisable to disable or turn off the ViewState management process whenever there is no need for the same in any application or Web Form.

There is a provision in ViewState management for turning off on a per-control basis or else you can even disable totally for a form by using the enable/disable feature. Whenever the ViewState is to be turned off for a particular control, then the same can be set in the property of that particular control. And for enabling/disabling or for turning on/turning off View State for all the controls of a page, you have to declare it in the corresponding attribute like EnableViewState=true/false at the top of the page itself. In ASP.NET the ViewState management attribute is set to true or enabled by default.


“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

| Privacy Policy for www.dotnet-guide.com | Disclosure | Contact |

Copyright - © 2004 - 2024 - All Rights Reserved.