Today I have noticed the existance of an attribute inside System.Web.UI namespace, that made me curious. The attribute was: NonVisualControlAttribute. It was the first time I have seen it (or I don't remember it).
What does this attribute do? The name suggests that it maybe used by some visual tools. The MSDN documentation is not very useful (as usual) providing only information I have already figured out just by looking at the class name: "Defines the attribute that indicates whether a control is treated as a visual or non-visual control during design time" (MSDN).
So what does this attribute do? I have searched the Internet for a while and found nothing useful, other than what I already knew. Then I have found that Visual Studio 2005 allows you to toggle whether to display Non Visual Controls using View menu. (you have to be in design mode to see this option). When you select not to display Non Visual Controls, they disappear from the design view like it would be expected. Is it useful? I don't know I have never needed such a feature and fortunately, by default, everything is visible.
Being curious, I have checked which controls have the NonVisualControl attribute applied and I have found that there are only 5 in the BCL:
When you look at the controls above, the important thing to notice is that "Non Visual" does not mean that the control does not render any html markup. As you can see, the HiddenField is also a NonVisualControl but it renders an input tag. WebPartManager on the other hand renders some JavaScript code.
Finally I have found a post on the very attribute written by Nikhil Kothari where he says the following: "Hopefully, it will be used to do more in the future, so start using it now, where it makes sense."
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 2008, Michal Talaga
E-mail