How view state is maintaing in asp.net

  • Thread starter Thread starter archana
  • Start date Start date
A

archana

Hi all,

I am new to asp.net. I am not very much clear in concept of
viewstate.

CAn anyone help me in understanding this concept. I have one question
regarding viewstate.

I have one aspx page with enableviewstate property set to true. So
when i run my application in
in html code of page i found _viewstate with some value.

My question is how server preserver viewstate between two page
request. Means next time when i send request for same page how it will
load content from previous viewstart.

Any help will be truely appreciated.
 
Look at the viewstate as a "property bag" where you can place hidden
variables. In the old days of ASP, if you wanted to remember info between
page requests that wasn't contained in a visible form element, you had to
store it in a HIDDEN field. The viewstate is just asp.net taking control of
these hidden fields. Rather than creating lots of them, it encodes them all
into one big variable.

When your page is rendered, the state of each control (eg if a dropdown
list, all of the list items) is encoded into the viewstate. On a PostBack,
this variable is read from the form and decoded to preserve the state of any
controls you had etc.
 
Back
Top