how does ASP.NET work

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
 
K

Karl Seguin

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top