-Dman100-
asked on
loop thru HTML generic controls
I have a series of html labls on my page with the runat="server" added to the tag.
Each <label> tag has an id and I created an array of the id names. I am trying to loop thru the array and find the labels on the page and perform an action.
This is what I tried, but it does not find the element on the page:
protected void Find()
{
string[] controls = { "a", "b", "c", "d" };
foreach (string ctrl in controls)
{
HtmlGenericControl lbl = (HtmlGenericControl)Page.F indControl (ctrl);
lbl.Visible = false;
//Response.Write(lbl);
}
}
How can I loop thru these page elements by their id?
In javascript, it was just a matter of using getElementById, and I thought I could use FindControl with .net, but it doesn't seem to work.
Thanks for any help.
Each <label> tag has an id and I created an array of the id names. I am trying to loop thru the array and find the labels on the page and perform an action.
This is what I tried, but it does not find the element on the page:
protected void Find()
{
string[] controls = { "a", "b", "c", "d" };
foreach (string ctrl in controls)
{
HtmlGenericControl lbl = (HtmlGenericControl)Page.F
lbl.Visible = false;
//Response.Write(lbl);
}
}
How can I loop thru these page elements by their id?
In javascript, it was just a matter of using getElementById, and I thought I could use FindControl with .net, but it doesn't seem to work.
Thanks for any help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you posted your aspx page, I could tell you what you could try.