Enumerating Web Controls


I want to loop through all of the controls on a page and check for those that have a certain property AND are WebContainer types. If the property exists, we can do something with it. I used the example introspection code from here:


The code I have so far is below:

[code]//Loop through all page controls and see what type they are
dim i as Integer
dim h as Webobject
dim ti as Introspection.TypeInfo
dim props() as Introspection.PropertyInfo

for i = 0 to self.ControlCount

h = self.ControlAtIndex(i)

if h <> nil then

//Below stuff came from: https://forum.xojo.com/4772-introspection-property-from-class/0
if h isa WebContainer then

ti = Introspection.GetType(h)
props() = ti.GetProperties()

//Check for our specific flag property
for each p as Introspection.PropertyInfo in props

if p.Name = “GeneralForm” then

msgbox “Got one !” //Get this for the WebContainers on the page so it is correct

// Now call a functuon with this ‘container’ reference
call foo(h)


The problem is that the foo method is expecting a WebContainer object rather than a WebObject object. Is there an easy way to get at the WebContainer which the above code tests for successfully such that I can then pass it on ?

Thanks in advance for any assistance,

Figured it out. Posting for anyone else who needs it and future me:


The relevant code is:

dim cont as WebContainer cont = webcontainer(self.ControlAtIndex(i))