how does ASP.NET work

  • Thread starter Thread starter Secret Squirrel
  • Start date Start date
S

Secret Squirrel

Hi,


1)
So I have a Textbox server side control. I edit the value in the
control client side, in my browser, and postback by clicking a button.

Now on the server-side, the request is handled, and then a response is
sent back to the browser. Let's say server does nothing, so the page is
just loaded again.

At what point in this process is the viewstate updated with the value
that I set?

2) If I change the value on a attribute of the textbox client-side and
then postback, should I expect to see the value of that attribute
maintained when the page is reloaded? How does ASP.NET manage this if
so?

Thanks!

SecretSquirrel
 
Secret:
You might find some answers by looking at (indirectly):
http://openmymind.net/FAQ.aspx?documentId=1

Basically, values are maintained via two separate collections. Request.Form
and ViewState. When items are added to a dropdownlist in codebehind, they
are also added to the viewstate. When a button is clicked, the items are
recreated from teh viewstate. Then ASP.Net looks at REquest.Form for the
dropdownlist and knowns which item was selected and selects it. Values
changed on the client, such as attributes, aren't passed in Request.Form
(this is an HTML thing) and aren't added to the viewstate (nothing
client-side is ever added to the viewstate)...so that change is lost.
Viewstate only persists things added to it on the server (during the
SaveViewState method, which happens before Render and after prerender).

you might also learn more from:
http://msdn.microsoft.com/library/d...guide/html/cpconControlExecutionLifecycle.asp

Karl
 
Back
Top