469,299 Members | 2,079 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,299 developers. It's quick & easy.

looping through controls collection


I am not farmilar with the object model for webforms.

I want to loop through the web form controls - pulling out the checkboxes on
the form like the following:

For Each ctrl In Me.Controls

If TypeOf ctrl Is CheckBox Then

'do something here.....

End If

Next

This works fine with windows forms of course...

But completely misses the dozen web checkboxes I have on my web form. Is
there an alternative syntax for web forms? Please note that I am not
refering to html checkboxes but the web control checkboxes.

thanks.
Jan 30 '06 #1
7 4844
Are the checkboxes maybe in a container control?

"astro" <as***@bcmn.com> wrote in message
news:Ka******************@tornado.rdc-kc.rr.com...

I am not farmilar with the object model for webforms.

I want to loop through the web form controls - pulling out the checkboxes
on the form like the following:

For Each ctrl In Me.Controls

If TypeOf ctrl Is CheckBox Then

'do something here.....

End If

Next

This works fine with windows forms of course...

But completely misses the dozen web checkboxes I have on my web form. Is
there an alternative syntax for web forms? Please note that I am not
refering to html checkboxes but the web control checkboxes.

thanks.

Jan 30 '06 #2

The control hierchy is:

form
---> html grid layout panel
-------->> html table
---------->>> webctrl checkbox

The loop has 3 iterations, one having the form1 as an ID, the other two
having no ID at all. I even placed additional webctrl checkboxes on the
form itself - and they were not found in the controls collection....

I've played around with this a bit and if I place the checkboxes in a
webctrl panel I can successfully iterate via the panel1.controls
collection... so this is what I am going to do....
"Marina Levit [MVP]" <so*****@nospam.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
Are the checkboxes maybe in a container control?

"astro" <as***@bcmn.com> wrote in message
news:Ka******************@tornado.rdc-kc.rr.com...

I am not farmilar with the object model for webforms.

I want to loop through the web form controls - pulling out the checkboxes
on the form like the following:

For Each ctrl In Me.Controls

If TypeOf ctrl Is CheckBox Then

'do something here.....

End If

Next

This works fine with windows forms of course...

But completely misses the dozen web checkboxes I have on my web form. Is
there an alternative syntax for web forms? Please note that I am not
refering to html checkboxes but the web control checkboxes.

thanks.


Jan 30 '06 #3
Right, this would be the same in windows forms. If you had your checkboxes
nested in a panel or some other container control,you would have to use the
same technique in windows forms.

I am not sure why you say that the checkboxes were not found even when
placed on the form itself, I've never had that problem. Perhaps you thought
they were directly on the form, but they were really inside some other
control.

"astro" <as***@bcmn.com> wrote in message
news:TQ******************@tornado.rdc-kc.rr.com...

The control hierchy is:

form
---> html grid layout panel
-------->> html table
---------->>> webctrl checkbox

The loop has 3 iterations, one having the form1 as an ID, the other two
having no ID at all. I even placed additional webctrl checkboxes on the
form itself - and they were not found in the controls collection....

I've played around with this a bit and if I place the checkboxes in a
webctrl panel I can successfully iterate via the panel1.controls
collection... so this is what I am going to do....
"Marina Levit [MVP]" <so*****@nospam.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
Are the checkboxes maybe in a container control?

"astro" <as***@bcmn.com> wrote in message
news:Ka******************@tornado.rdc-kc.rr.com...

I am not farmilar with the object model for webforms.

I want to loop through the web form controls - pulling out the
checkboxes on the form like the following:

For Each ctrl In Me.Controls

If TypeOf ctrl Is CheckBox Then

'do something here.....

End If

Next

This works fine with windows forms of course...

But completely misses the dozen web checkboxes I have on my web form.
Is there an alternative syntax for web forms? Please note that I am not
refering to html checkboxes but the web control checkboxes.

thanks.



Jan 30 '06 #4

what is the parent container of the checkboxes here? what would the syntax
be?
In vb.net the 'me' pronoun is a quick way of getting to the form - which is
usually the container..using recursion I can drill down any subcontainer and
get it's controls. How would I implement a similar strategy for webforms?

Thanks.

(thanks for the feedback Marina btw)
"Marina Levit [MVP]" <so*****@nospam.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
Right, this would be the same in windows forms. If you had your checkboxes
nested in a panel or some other container control,you would have to use
the same technique in windows forms.

I am not sure why you say that the checkboxes were not found even when
placed on the form itself, I've never had that problem. Perhaps you
thought they were directly on the form, but they were really inside some
other control.

"astro" <as***@bcmn.com> wrote in message
news:TQ******************@tornado.rdc-kc.rr.com...

The control hierchy is:

form
---> html grid layout panel
-------->> html table
---------->>> webctrl checkbox

The loop has 3 iterations, one having the form1 as an ID, the other two
having no ID at all. I even placed additional webctrl checkboxes on the
form itself - and they were not found in the controls collection....

I've played around with this a bit and if I place the checkboxes in a
webctrl panel I can successfully iterate via the panel1.controls
collection... so this is what I am going to do....
"Marina Levit [MVP]" <so*****@nospam.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
Are the checkboxes maybe in a container control?

"astro" <as***@bcmn.com> wrote in message
news:Ka******************@tornado.rdc-kc.rr.com...

I am not farmilar with the object model for webforms.

I want to loop through the web form controls - pulling out the
checkboxes on the form like the following:

For Each ctrl In Me.Controls

If TypeOf ctrl Is CheckBox Then

'do something here.....

End If

Next

This works fine with windows forms of course...

But completely misses the dozen web checkboxes I have on my web form.
Is there an alternative syntax for web forms? Please note that I am
not refering to html checkboxes but the web control checkboxes.

thanks.



Jan 30 '06 #5
You'll need a recursive loop to do this kind of thing reliably.
Here are the details:
http://SteveOrr.net/faq/ControlTreeRecursion.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"astro" <as***@bcmn.com> wrote in message
news:Ka******************@tornado.rdc-kc.rr.com...

I am not farmilar with the object model for webforms.

I want to loop through the web form controls - pulling out the checkboxes
on the form like the following:

For Each ctrl In Me.Controls

If TypeOf ctrl Is CheckBox Then

'do something here.....

End If

Next

This works fine with windows forms of course...

But completely misses the dozen web checkboxes I have on my web form. Is
there an alternative syntax for web forms? Please note that I am not
refering to html checkboxes but the web control checkboxes.

thanks.

Jan 30 '06 #6
arhg!

"page.controls".......that was what I was missing!

Thanks

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl...
You'll need a recursive loop to do this kind of thing reliably.
Here are the details:
http://SteveOrr.net/faq/ControlTreeRecursion.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"astro" <as***@bcmn.com> wrote in message
news:Ka******************@tornado.rdc-kc.rr.com...

I am not farmilar with the object model for webforms.

I want to loop through the web form controls - pulling out the checkboxes
on the form like the following:

For Each ctrl In Me.Controls

If TypeOf ctrl Is CheckBox Then

'do something here.....

End If

Next

This works fine with windows forms of course...

But completely misses the dozen web checkboxes I have on my web form. Is
there an alternative syntax for web forms? Please note that I am not
refering to html checkboxes but the web control checkboxes.

thanks.


Jan 30 '06 #7
I don't know - whatever you put on there. I am just saying maybe you didn't
realize you were putting the checkboxes in there.

What you describe it exactly how it works with web forms. Which is exactly
how it works with windows forms. You say Me.Controls, and then loop
through it, and use recursion to loop through the controls of each control,
etc.

"astro" <as***@bcmn.com> wrote in message
news:Ni******************@tornado.rdc-kc.rr.com...

what is the parent container of the checkboxes here? what would the
syntax be?
In vb.net the 'me' pronoun is a quick way of getting to the form - which
is usually the container..using recursion I can drill down any
subcontainer and get it's controls. How would I implement a similar
strategy for webforms?

Thanks.

(thanks for the feedback Marina btw)
"Marina Levit [MVP]" <so*****@nospam.com> wrote in message
news:e9**************@TK2MSFTNGP10.phx.gbl...
Right, this would be the same in windows forms. If you had your
checkboxes nested in a panel or some other container control,you would
have to use the same technique in windows forms.

I am not sure why you say that the checkboxes were not found even when
placed on the form itself, I've never had that problem. Perhaps you
thought they were directly on the form, but they were really inside some
other control.

"astro" <as***@bcmn.com> wrote in message
news:TQ******************@tornado.rdc-kc.rr.com...

The control hierchy is:

form
---> html grid layout panel
-------->> html table
---------->>> webctrl checkbox

The loop has 3 iterations, one having the form1 as an ID, the other two
having no ID at all. I even placed additional webctrl checkboxes on the
form itself - and they were not found in the controls collection....

I've played around with this a bit and if I place the checkboxes in a
webctrl panel I can successfully iterate via the panel1.controls
collection... so this is what I am going to do....
"Marina Levit [MVP]" <so*****@nospam.com> wrote in message
news:en**************@TK2MSFTNGP09.phx.gbl...
Are the checkboxes maybe in a container control?

"astro" <as***@bcmn.com> wrote in message
news:Ka******************@tornado.rdc-kc.rr.com...
>
> I am not farmilar with the object model for webforms.
>
> I want to loop through the web form controls - pulling out the
> checkboxes on the form like the following:
>
> For Each ctrl In Me.Controls
>
> If TypeOf ctrl Is CheckBox Then
>
> 'do something here.....
>
> End If
>
> Next
>
> This works fine with windows forms of course...
>
> But completely misses the dozen web checkboxes I have on my web form.
> Is there an alternative syntax for web forms? Please note that I am
> not refering to html checkboxes but the web control checkboxes.
>
>
>
> thanks.
>
>



Jan 30 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Shloma Baum | last post: by
1 post views Thread by msnews.microsoft.com | last post: by
5 posts views Thread by greg | last post: by
3 posts views Thread by Charlie Brown | last post: by
1 post views Thread by Tina | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.