Do we really even need IStateManager anymore now that we have ASP.NET AJAX? In the olden days IStateManager was used to retain the state changes made to a list-bases resource. These changes would occur on the server and be available on the next postback. Let's provide a brief example, and I have the perfect one: the DropDownList control. The DropDownList control (and other ListControl derivatives) have an Items property of type ListItemCollection. This list class implements IStateManager, so any changes to the Items collection on the server is retained and "permanently" available, at least available while that page was existant. So a page could bind a list, then later on use server code to change the list (say in a postback scenario), and these changes are retained. Some developers even wrap the DropDownList in an updatepanel in order for this to work, or use the AjaxControlToolkit (ACT) extender to manage multiple related drop downs.
Note: I Expect You to Understand IStateManager and what it's used for beyond this point.
Now that the focus and the toolset is moving toward a rich client-side AJAX-centric applications, more based on JavaScript than using the server-based UpdatePanel approach, do we even need to consider IStateManager for any custom controls we may develop? In some cases, I say no, that this isn't as much of a concern anymore.
In some cases, I still say yes, and here is why. Suppose you have a list of drop down items for a customized drop down control. Your control can and does manipulate the list of items on the client, while retaining an equivalent list on the server (which is the norm for ASP.NET AJAX controls in most cases). You may want those two lists to retain the same values, and so one way to do this is to ensure the list retains its values using IStateManager, and post back the changes to the list in a hidden field or something else.
ASP.NET AJAX doesn't have a direct way to postback values, so storing information in hidden fields or another client-side mechanism is the common choice for doing this. This means that a list of entries may be written in a JSON, or other, format and be processed on the server. The server can process hidden field information in LostPostData, and thus modify the list at the appropriate time, which IStateManager can then do its work at the appropriate time.
My random thought for today (or actually tonight technically).
Image may be NSFW.Clik here to view.
