Search result for 'findcontrol recursive c'
(0.0125730037689 seconds)
1 pages :
1
James Avery/Recursive FindControl ( ASP.NET)
public static Control FindControlRecursive(Control root, string id)
{
if (root.ID == id)
{
return root;
}
foreach (Control c in root.Controls)
{
Control t = FindControlRecursive(c, id);
if (t != null)
{
return t;
}
}
return null;
}
A recursive find control that loops through a page and all its child pages/controls to find a control.
Nakor/Recursive FindControl using Predicate ( ASP.NET)
public static T FindControl<T>(this Control control, Predicate<Control> expression) where T: Control
{
T tmp = null;
if (control.HasControls())
{
foreach (Control ctrl in control.Controls)
{
if (tmp == null)
{
if (ctrl is T)
{
if (expression == null || expression.Invoke(ctrl))
return (ctrl as T);
}
else
{
if (ctrl.HasControls())
tmp = FindControl<T>(ctrl as Control, expression);
}
}
else break;
}
}
return tmp;
}
Recursively locate a child control based on the predicate statement parameter. Returns the actual instance of the control rather than a generic control that needs to be cast.