ViewState Problem...PLEASE HELP!

  • Thread starter Thread starter Moshfegh Hamedani
  • Start date Start date
M

Moshfegh Hamedani

Hi there,

I have a simple web page containing a text box and a button. I set the
EnableViewState property of the text box to false. So, I expect that when I
type some text in the text box and hit the button, the text is not set to
the Text property of the text box after the page is posted back. But it
doesn't work at all !!! I even set the Page.EnableViewState to false but it
still loads view state data into text box after posting back.

So, what's the usage of View State ?!!! Any one here has any idea on this?

Please let me know,
Mosh
 
The text property is being set because it is not using viewstate. You are
setting the text, it is being posted to the server and the ASP.NET framework
is populating the appropriate control property. ViewState comes into play if
you want to do something once on a page_load, for example, and then allow
ViewState to maintain the state of the control. For instance, you could
populate a dropdownlist with items the first time the user hits the page and
then allow viewstate to maintain those items via its hidden form field
__VIEWSTATE.
 
Back
Top