I have a page with a number of controls.
As the page is rendering I want to loop through all controls on the page and find any control that has a property with certain attribute. I am attempting to do this with c# – any ideas how I might achieve this?
I dont know how big is your control tree. This is what I would do. I’m not promissing the best performance.
Case 1. Looking for .NET Attributes
Case 2. Looking for HTML attributes
Now you can call it this way:
var controlsWAttribute = GetMarkedControls(this.Controls);from your page or any control. This way you are not forced to call it at the page level.With this method you explore the whole control tree in your page or control recursively.