Hi..
How can we use View Statement technique in ASP.NET and define its uses?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Jan 23, 2012, 2:08 AM EST
Viewstate represents the state of the page when it was last processed on the server. We use it to retain values across two successive requests for the same page. It is a hidden field added to the page and is restored on the server before the page request is processed. The Viewstate information travels back and forth with the page itself, but contains no visual elements that need to be rendered
Please refer the below links
http://aspnetresources.com/articles/ViewState
http://weblogs.asp.net/dotnetstories/archive/2009/10/19/viewstate-management-in-asp-net-4-0.aspx
http://www.codeproject.com/Articles/18705/Manage-ViewState-Using-ASP-NET-2-0-Provider-Archit
Thanks
Anuja PawarRank #1,404 · 1.2K reputationPosted Jan 24, 2012, 12:42 AM EST
ViewState is the mechanism that allows state values to be preserved across page postbacks.
Because of the stateless nature of web pages, regular page member variables will not maintain their values across postbacks. When we need a page variable to maintain its value across page post backs, we can use ViewState to store that value. Values stored in ViewState will be serialized and sent to the client browser as the value of a hidden form input. 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:
This single hidden field contains all the viewstate values for all the page controls. This is an important aspect of viewstate that you need to consider.
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 (In asp.net 2.0, ViewState is enabled by default). When ViewState is disabled for any control, it will also automatically be disabled for all child controls of that control.
Refer this article for more depth
http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx
http://msdn.microsoft.com/en-us/library/ms972976.aspx