Posts
391
Comments
137
Trackbacks
0
Generische Methode FindControlRecursive

Fürs Archiv eine generische Methode FindControlRecursive:

public static T FindControlRecursive<T>(Control parent, string id) where T : class
{
   foreach (Control child in parent.Controls)
   {
      if ((child.ID != null)
         && string.Equals(child.ID, id, StringComparison.InvariantCultureIgnoreCase)
         && (child is T))
         return (child as T);
 
      var ctl = FindControlRecursive<T>(child, id);
      if (ctl != null)
         return ctl;
   }
   return null;
}
posted on Monday, January 11, 2010 1:26 PM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 6 and 8 and type the answer here: