FindParent
public static T FindParent<T>(this Control target) where T : Control { if (target.Parent == null) { return null; } var parent = target.Parent as T; if (parent != null) { return parent; } return target.Parent.FindParent<T>(); }Example:
someControl.FindParent<RepeaterItem>().UniqueID;
Description
A simple type safe method to find a parent control
Details
- Author: Rob White
- Submitted on: 12/13/2010 8:57:02 PM
- Language: C#
- Type: System.Web.UI.Control
- Views: 3171
Double click on the code to select all.