Very simple viewstate question

S

Sahil Malik

In VS2003 - add a page.
Add a button
Add a textbox.

Set EnableViewState = False for all 3 above.

Put some code behind on Button (anything).

Run the sample - type something in the textbox - hit the button - ..
viewstate is false .. the textbox after postback should contain nothing ..!!

Unfortunately the value of the textbox remains .. What is going on??

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
http://blogs.apress.com/authors.php?author=Sahil Malik
 
K

Karl Seguin

Textboxes maintain their state without viewstate. That's because they don't
need viewstate to be persistant - their values are automatically submitted
via the form. You might think the same is true for a dropdown, but only the
selected value is passed in the form which is why disabling viewstate for it
(or other controls) makes the value disapear.

you'll need to manually set it to ""

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

Top