Recursively Iterate All Form/Panel Controls On A Page

  • Thread starter Thread starter Dan Sikorsky
  • Start date Start date
D

Dan Sikorsky

How do you recursively iterate thru each collection on each form on a web
page and find each web control?
 
Here's a solution:

Private Sub IterateControls(ByRef ctlParent As Control)
Dim ctlControl As Control

For Each ctlControl In ctlParent.Controls
Select Case ctlControl.GetType.ToString
Case "System.Web.UI.WebControls.TextBox"

Case "System.Web.UI.WebControls.RadioButtonList"

Case "System.Web.UI.WebControls.DropDownList"

End Select
If ctlControl.HasControls Then
IterateControls(ctlControl)
End If
Next
End Sub

Thank you kindly,
Dan Sikorsky BAB, BScE, MSC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top