How view state is maintaing in asp.net

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.
 
A

Aidy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top