Loop through controls with MaterPage ContentHolder

S

Steven K

Hello,

I just worked through finding controls on a page with and without a panel.
My question is how do you loop through controls if you are using a master
page and your content is inside the ContentHolder control?

Thanks in advance, Steven


Sub FindControlsInWebForm()
Dim strValue As String = ""

'Loop through controls
For Each ctlPage As Control In Page.Controls
If TypeOf ctlPage Is HtmlForm Then
For Each ctlChild As Control In ctlPage.Controls
If TypeOf ctlChild Is Label Then strValue &= "Page.Label.ID = " &
ctlChild.ID & ".ID<br>"

'Panel
If TypeOf ctlChild Is Panel Then
strValue = "Panel.ID = " & ctlChild.ID & ".ID<br>"

For Each ctlGrndChild As Control In ctlChild.Controls
If TypeOf ctlGrndChild Is TextBox Then strValue &=
"Panel.TextBox.ID = " & ctlGrndChild.ID & ".ID<br>"
Next ctlGrndChild
End If
Next ctlChild
End If
Next ctlPage
End Sub
 

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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,709
Latest member
AustinMudi

Latest Threads

Top