Friday, August 19, 2016

ViewState

  • Track the values in the Controls
  • You can add custom values to the view state. 
  • It is used by the Asp.net page framework to automatically save the values of the page and of each control just prior to rendering to the page. When the page is posted, one of the first tasks performed by page processing is to restore view state. 
  • Viewstate enable and disabled at application level (web.config), page and control.
ViewState is more secure than hidden field, although viewstate internally will store with hidden field.
  • It is page-level State Management, it page only, cannot cross page.
  • Can store any type of data 
  • For Small Size Data only (Simple Data)
  • No Server Resource, within a page
  • Support Encryption Decryption
  • Can store object  or List of object (but need to serialize the class)
  • No Time out.
  • base64 encoded
Disadvantage
  • It does not have any support on mobile devices
  • it can seen in page (source), you need extra code to encrypt it.
  • Sore a large value will cause page slow.
Using ViewStateMode
  • Disable viewstateMode at Parent, Enable it at child level –> Works well
  • Enable viewstateMode  at Parent, Disable it at child level –> Works well
Using EnableViewState
  • Disable EnableViewState at parent, Enable it at child –> Does not work
  • Enable EnableViewState  at parent, Disable it at child –> Works well

No comments:

Post a Comment