Hi All,
Can anybody explain ViewState(in ASP.NET) as short as possible.
Hi All,
Can anybody explain ViewState(in ASP.NET) as short as possible.
From here:
ViewState allows the state of objects (serializable) to be stored in a hidden field on the page. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source. ViewState is used the retain the state of server-side objects between postabacks.
ViewState is the mechanism that allows state values to be preserved across page postbacks.
The web is stateless. But in ASP.NET, the state of a page is maintained in the page itself automatically.This is done Using ViewState.In ViewState the values are encrypted and saved in hidden controls.
When you view the page source (in your browser) of a page the uses ViewState, you may see this hidden viewstate
input which will look something like this:
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTM1ODM3Nj......." />
This single hidden field contains all the viewstate values for all the page controls.
Because viewstate is (by default) sent to the client browser and then returned to the server in the form of a hidden input control on your page, storing a significant amount of data in viewstate can increase your page size and can affect your page performance.
To disable ViewState for a control, you can set the EnableViewState property to false.
If you want more information take a look on MSDN article
"Understanding ASP.NET View State" http://msdn.microsoft.com/en-us/library/ms972976.aspx
In short,