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);
}
}
}
public void FindControlsRecursively(Control oControl)
{
foreach (Control frmCtrl in oControl.Controls)
{
Response.Write(frmCtrl.GetType().ToString() + "
");
if (frmCtrl.HasControls())
{
FindControlsRecursively(frmCtrl);
}
}
}
Comments
Software Engineer
T M Technologies
જય વાળીનાથ said…
Thank you..