using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
namespace Umbraco.Core
{
internal static class ControlExtensions
{
///
/// Recursively finds a control with the specified identifier.
///
///
/// The type of control to be found.
///
///
/// The parent control from which the search will start.
///
///
/// The identifier of the control to be found.
///
///
/// The control with the specified identifier, otherwise if the control
/// is not found.
///
public static T FindControlRecursive(this Control parent, string id) where T : Control
{
if ((parent is T) && (parent.ID == id))
{
return (T)parent;
}
foreach (Control control in parent.Controls)
{
var foundControl = FindControlRecursive(control, id);
if (foundControl != null)
{
return foundControl;
}
}
return default(T);
}
}
}