What is the view state of ASP.NET?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

What is the view state of ASP.NET?

Rating:

ASP.NET uses a technique known as the view state. This technique is used to persist changes to the state of a Web page across postbacks. ASP.NET that manages a nonpostback Web server control such as Label control does not post its values as part of the postback operation to the Web server. ASP.NET collects all the values of the nonpostback control, formats them into an encoded string and stores in a hidden input field on a Web page. By default, the view state of a Web page is placed in a hidden form field named _VIEWSTATE.

At the server-side, ASP.NET decodes the view state string during page initialization and restores the nonpostback values in the Web page. But this view state technique increases the size of the HTML file and the amount of time to load the page. To eliminate these drawbacks, ASP.NET provides a disabling feature that does not enable view state at various levels, which are as follows:

  • Control Level: To populate a control's state at each request, the view state can be disabled at the control level by setting the EnableViewState property of the control to false. For example, <asp: ListView EnableViewState="False" />.


  • Page Level: At the page level, setting the EnableViewState attribute of the @ Page directive to false can disable view state. For example, <%@ Page EnableViewstate="False" %>.

  • Application or Machine Level: View state can also be disabled by adding <pages enableViewState="false" /> to a Web.config file at the application level or to a Machine.config file at the machine level.


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us | News and Press Release | uCertify India
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.