Frequently Asked Interview Questions

Interview Questions on ViewState

FAQS on ASP.NET StateManagement
No
Yes, For all Asp.Net web server controls ViewState is enabled by default, to maintain the state between multiple roundtrips.
The ViewState property provides a dictionary object for retaining values between multiple requests for the same page.
When the page is processed, the current state of the page and controls is hashed into a string and saved in the page as a hidden field.(Web page HTML)
Every asp.net server control has a property called EnableViewState. We can set it to true/false.
By default it is set to true for every web server control
Page_Init event
ViewState data is hashed into a string and saved in the page as a hidden field.
For example:

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUJNzgzNDMwNTMzDxYCHgJpZAUGdGVzdElkZGQ3YjU2QEici7mzF6IA0sPhKHRhrQ==" />
To configure view state encryption for an application does the following:

<Configuration>
<system.web>
<pages viewStateEncryptionMode="Always"/>
</system.web>
</configuration>
<%@page -- ViewStateEncryptionMode=”Always”%>
No, ViewState of a page is available only in that page. You can not access ViewState of one page in other page.

Most Visited Pages

Home | Site Index | Contact Us