Reputation: 30303
Yesterday I went on an interview where the panel asked me this question.
Upvotes: 4
Views: 9311
Reputation: 48583
Items stored in view state are transmitted to the client's browser as HTML within a hidden control, and sent back to the server when the user posts from that page (details from the indispensable ViewState: All You Wanted to Know):
1) ASP.NET begins rendering the page. All objects in the current ViewState are serialized using a custom format that looks like this: t<1234567890;t<p<l<prpA;prpB;prpC;>;l<valA;valB;valC;>>;
2) That serialized data is encoded and written to an HTML hidden control on the ASP.NET page's form, where it looks like this (simulated data): dDwxMjM0NTY3ODkwO3Q8cDxsPHBycEE7cHJw
3) At this point the items are latent on the client's browser: you might say they're 'hibernating.'
4) If the client posts the page, ASP.NET decodes and deserializes the view state data into objects again, and they 'live' until the request is over (or until they are written to another page).
Upvotes: 4
Reputation: 9317
It exists till your current page exists. ViewState persist the values of controls of particular page in the client when post back operation done. Then user requests another page previous page data no longer available.
Upvotes: 3