FindControlByType

public static T FindControlByType<T>(this Control ctrl)
{
  return ctrl.GetChildren().OfType<T>().SingleOrDefault();
}
Example:
DistinctType dt= Control.FindControlByType<DistinctType>();

Description

Used in conjunction with GetChildren(), it will return a T from a list of children of a control. If you are looking to return a list of T, use FindControlsByType() at http://www.extensionmethod.net/Details.aspx?ID=310 Get Children is located at: http://www.extensionmethod.net/Details.aspx?ID=309

Details

Double click on the code to select all.

 

;