Hi guys,
What is the lifespan for items stored in ViewState?
Lifespan of ViewState
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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
SenthilkumarRank #387 · 6.5K reputationPosted Apr 9, 2012, 3:51 AM EDT
The viewstate is designed to store the value in the viewstate only for the life of the current page. It serialize and deserialize the data whenever store and retrieve. It will be stored on the hidden control in client side and value persisted across the postback.
It will maintain the view state only for the life time of the current page.
If you want to maintain data persist across the pages then you need to use the SessionState, ApplicationState or database.
Keyur Narkhi62 reputationPosted Apr 8, 2012, 8:33 PM EDT
In asp.net when a form is submitted,form is loaded back with the all the values because of viewstate.
The ViewState indicates the status of the page when submitted to the server. The status is defined through a hidden field placed on each page with a
So the viewstate's life is upto page level.
Thanks
MuthuMari MRank #5,738 · 288 reputationPosted Apr 8, 2012, 8:37 PM EDT
Items stored in the ViewState exist for the life of the current page.
This includes postbacks (to the same page).
For more info :
http://stackoverflow.com/questions/3832657/what-is-life-span-for-items-stored-in-view-state
thanks
If this post is useful then mark it as "Accepted Answer"