Want to loop through all the user controls that exist on the page and get their IDs. How do I do it?
I created an extension method to do this, which works really nicely with LINQ.
Public Function DecendentControls(ParentControl As Control) As Control()
Dim controls As New List(Of Control)
For Each myControl As Control In ParentControl.Controls
controls.Add(myControl)
controls.AddRange(myControl.DecendentControls)
Next
Return controls.ToArray
End Function
Then with LINQ you can do something like this to set all the checkboxes on a page to unchecked:
For Each myControl As CheckBox In pnlMain.DecendentControls.Where(Function(x) TypeOf x Is CheckBox)
myControl.Checked = False
Next