ViewState / IStateManager

System.Web.UI.IStateManager has methods called TrackViewState, IsTrackingViewState, LoadViewState, SaveViewState

System.Web.UI.Control has methods TrackViewState, IsTrackingViewState, LoadViewState, SaveViewState

And yet Control doesn't implement IStateManager. Why not?

On Control, TrackViewState is protected. This means that when dynamically constructing a control tree, the only way to enable ViewState tracking is to add the control to its parent . This makes it more difficult to create and initialize a control in a nice separate helper function.

This annoys me.

1 Comment

  • I agree with you on Control not implementing IStateManager. It doesn't really need to and IStateManager is there to give other objects the same familiar pattern that's integrated into the Control class. But it would have been nice if Microsoft would have maintained consistency and given the Control class the same state management methods through the same interface they preach that you use on your objects. It annoys me too.

Comments have been disabled for this content.