void RecurseFindControls(Control c, ref System.Text.StringBuilder sb, ref int iLevel)
{
if (c.ID != null)
{
sb.Append ( c.ID + "[" + iLevel.ToString () + "];" );
}
if ( c.Controls.Count > 0 )
{
iLevel++;
for ( int j = 0 ; j < c.Controls.Count ; j++ )
{
RecurseFindControls ( c.Controls[ j ], ref sb, ref iLevel );
}
}
}
A Southwestern adventurer striking out into the badlands of the Midwest for fun, profit, and for a wife who wouldn't move back to the Southwest :)
Thursday, October 16, 2008
Basic: A Recursive Function to Find All Control ID's in a Control
Sometimes you might have a control that has a lot of other controls burried in it. Here is a small very basic recursive function to find all the control id's. I'm posting it more for my reference. Just pass in a string builder and an int.
Labels:
ASP.Net,
C#,
Web Development
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment