473,385 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 5129
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jeffrey Todd | last post by:
I need to process a specific Control in a Web Page's Controls collection. I do know the ID of the control. I simply need to pass a reference to it to another method. The following code works...
0
by: Jeff Dockman | last post by:
Background: We needed the ability to create a templated web site that may change in layout from installation to installation. To accomplish this, we created a base Page class that all pages in...
1
by: Shloma Baum | last post by:
Hi, I would like to ask if there is something similer (even in a diffrent way) to loop all controls on a component in the same way there is on a form.controls collection? Thanks in advance...
1
by: msnews.microsoft.com | last post by:
I'm adding multiple web controls to the placeholder controls collection, but even when doing the for each and recursion method of getting the web controls, I'm only getting the first web control...
7
by: Rich | last post by:
Hello, I have a form with 5 textboxes named txt0, txt1, txt2, txt3, tx4. In VB6 I could iterate through these with For i = 0 to 4 debug.print Me.controls("txt" & i).Name Next
5
by: greg | last post by:
HI, I have an asp page that loops through the forms collection gathering data from input controls that web surfers have entered in. The problem I have is when I get to the submit button, I get...
3
by: Charlie Brown | last post by:
I am adding controls to the Forms controls collection at run-time. Then when I loop through the controls and list them by name, I am missing half my controls. Is there a workaround? Debugger...
1
by: Tina | last post by:
I have a DataGrid Item from the header row of a 1.1 DataGrid. I got it by saying... Dim HeaderItem As DataGridItem = mygrid.Controls(0).Controls(0) Now I'm looping through the Header item...
4
by: John Dalberg | last post by:
I am looking at a problem which is preventing my code to get a reference to any asp control inside a div section which has a runat=server attribute. This can be reproduced in a simple test:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.