ViewState (De)mystification
In about of a year of .NET development, I had somehow stayed away from the nitty-gritties of ASP.NET. Today, out of the blue, I got this urge to create a custom composite control. After an inevitable struggle, I did manage to do what I wanted to. In the process, I came to know that my knowledge of ViewState was incomplete (crappy in other words) and later got enlightened by this brilliant article written by Paul Wilson, an ASP.NET MVP: ViewState: All You Wanted to Know.
Here's what I understand (in brief): ViewState would contain only that information/properties about controls that are lost after the page is dispatched to the browser. That is, those properties that are not available when post back happens. For example, formatting and style information etc. With this thought in mind, I browsed through the properties of (System.Web.UI.WebControls) TextBox control using Reflector, and I was surprised to see that the Text property was stored in ViewState too. I wondered why. Text is a property that does not need to be stored in ViewState as this is available through the Form collection and the value will be replaced with the Form value when Postback data is processed before the Load Event.
If someone knows why, please do let me know!!