Recursively Iterate All Form/Panel Controls On A Page

D

Dan Sikorsky

How do you recursively iterate thru each collection on each form on a web
page and find each web control?
 
D

Dan Sikorsky

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

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top