ExtensionMethod.NET Home of 876 C#, Visual Basic, F# and Javascript extension methods


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


public static T FindControlByType<T>(this Control ctrl)
  return ctrl.GetChildren().OfType<T>().SingleOrDefault();


DistinctType dt= Control.FindControlByType<DistinctType>();

Author: Ryan Helms

Submitted on: 18 jul 2010

Language: C#

Type: System.Control

Views: 4942