Help with controls on page

G

gbjornholm

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
 
G

gbjornholm

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




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?
 
B

bruce barker

writeControlIds(Page);

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


-- bruce (sqlwork.com)

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




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?
 

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,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top