Help with controls on page

  • Thread starter Thread starter gbjornholm
  • Start date Start date
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
 
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?
 
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?
 
Back
Top