By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,214 Members | 2,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,214 IT Pros & Developers. It's quick & easy.

Help with controls on page

P: n/a
I am trying to loop through all the controls on my webform to get it's
ID property. My eventual goal is going to be to reset the text of
specific contols.

Here is a piece of the code I am using, that I found searching through
Google:

Dim control As Control

For Each control In Me.Page.Controls
Response.Write("<BR>" + control.ID)
Next

Unfortunately, all I get returned is the name of my form such as
"frmIndex".

Anyone have any idea or, prefered, an example of what I need to do?

Thanks in advance

Jun 7 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Controls collection includes only direct children. You should loop
recursively to reach every control.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
<gb********@gmail.comwrote in message
news:11**********************@q66g2000hsg.googlegr oups.com...
>I am trying to loop through all the controls on my webform to get it's
ID property. My eventual goal is going to be to reset the text of
specific contols.

Here is a piece of the code I am using, that I found searching through
Google:

Dim control As Control

For Each control In Me.Page.Controls
Response.Write("<BR>" + control.ID)
Next

Unfortunately, all I get returned is the name of my form such as
"frmIndex".

Anyone have any idea or, prefered, an example of what I need to do?

Thanks in advance

Jun 7 '07 #2

P: n/a
On Jun 7, 3:18 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
Controls collection includes only direct children. You should loop
recursively to reach every control.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

<gbjornh...@gmail.comwrote in message

news:11**********************@q66g2000hsg.googlegr oups.com...
I am trying to loop through all the controls on my webform to get it's
ID property. My eventual goal is going to be to reset the text of
specific contols.
Here is a piece of the code I am using, that I found searching through
Google:
Dim control As Control
For Each control In Me.Page.Controls
Response.Write("<BR>" + control.ID)
Next
Unfortunately, all I get returned is the name of my form such as
"frmIndex".
Anyone have any idea or, prefered, an example of what I need to do?
Thanks in advance- Hide quoted text -

- Show quoted text -
Thanks. Do you have an example, or a link, on how to loop recursively
thru the form?
Jun 7 '07 #3

P: n/a
writeControlIds(Page);

void writeControlIds(Control pc)
{
foreach (Control c in pc)
{
Response.Write(c.ID + "<br />");
writeControlIds(c);
}
}
-- bruce (sqlwork.com)

gb********@gmail.com wrote:
On Jun 7, 3:18 am, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@mMvVpPsS.orgwrote:
>Controls collection includes only direct children. You should loop
recursively to reach every control.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

<gbjornh...@gmail.comwrote in message

news:11**********************@q66g2000hsg.googleg roups.com...
>>I am trying to loop through all the controls on my webform to get it's
ID property. My eventual goal is going to be to reset the text of
specific contols.
Here is a piece of the code I am using, that I found searching through
Google:
Dim control As Control
For Each control In Me.Page.Controls
Response.Write("<BR>" + control.ID)
Next
Unfortunately, all I get returned is the name of my form such as
"frmIndex".
Anyone have any idea or, prefered, an example of what I need to do?
Thanks in advance- Hide quoted text -
- Show quoted text -

Thanks. Do you have an example, or a link, on how to loop recursively
thru the form?

Jun 7 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.