Sunday, November 28, 2010

EnableViewState on ASP.NET Text box

While I was helping one of my friend this weekend in getting up to speed in ASP.NET basics, I was trying to demo View state by example and added couple of text boxes and a button control to showcase the stateless behavior of web and how view state helps(brings performance problems most of the times) developers to retain the values between post back.

But the sample app retains value between post back even after disabling the view state in control level and as well as in Page level. Puzzled a bit and tried to reproduce the same scenario with other controls such as check box and a calendar control. To make it worse for Calendar control the view state works as expected and for check box control, it maintains the state even though the view state is disabled.

After couple of minutes searched in Microsoft Knowledge base found this knowledge base article KB316813 which solves the puzzle stating that the following set of controls will persist value across requests even though the view state is disabled.

  • The TextBox control.
  • The CheckBox control.
  • The RadioButton control.

The values which are posted to the server are handled by the IPostBackDataHandler interface.

No comments: