GetChildren

public static IEnumerable<Control> GetChildren(this Control control)
    {
      var children = control.Controls.Cast<Control>();
      return children.SelectMany(GetChildren).Concat(children);
    }
Example:
IEnumerable<Control> children = Page.GetChildren();

or

IEnumerable<Control> children = Container.GetChildren();

Description

This is a recursive function to get all child controls under the target control.

Details

Double click on the code to select all.

 

;