Recursive function to find controls & child controls in asp.net 2.0

The following method can be used to find controls and their child controls with help of recursion.

public void FindControlsRecursively(Control oControl)
{
foreach (Control frmCtrl in oControl.Controls)
{
Response.Write(frmCtrl.GetType().ToString() + "
");

if (frmCtrl.HasControls())
{
FindControlsRecursively(frmCtrl);
}
}
}

Comments

Popular posts from this blog

Fetching Address book AKA Contact information from Device using Xamarin.Forms

Custom Attributes in MVC

Partial view and AJAX Form with MVC3 Razor