After reading my article on recursive properties of ASP.NET controls, where I point out that not all properties are recursive, I have decided to fix one annoying behavior. The problem is that one of the most important property of all, the EnableViewState property is not recursive. This of course makes it useless in most scenarios. Never will we be able to rely on it while authoring our controls since ViewState can be disabled on any of the parent controls thus preventing our control from saving its state.
To solve this a very simple method can be used to check for the state of EnableViewState property:
public bool IsViewStateEnabled(Control control) { if (control.Parent == null) { return control.EnableViewState; } return control.EnableViewState && IsViewStateEnabled(control.Parent); }
Remember Me
a@href@title, strike
Powered by: newtelligence dasBlog 2.0.7226.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2010, Michal Talaga
E-mail