View Full Version : Looping through HTML (or INFRAGISTICS) elements...

12-15-2009, 01:43 PM
Hi guys,
I am new around here so ... greetings!

I've lately stepped up a little problem with one of my personal projects that i am working.

I'm writing an aspx webpage, which includes web user controls inside it.

The webuser controls are within a web form (id=form1 runat=server) which resides in the

main.aspx page.

1. First of all, is there a way to find a SPECIFIC control inside the webuser control (ascx)

using Javascript in the main.aspx?

2. If not (which i think it is), which is the best way to do it?
The snippet i tried was this:

function FindControl(elem_type,elem_id)
var elem = document.form1.elements;
for(var i = 0; i < elem.length; i++)

if ((elem[i].type==elem_type) && (elem[i].id.indexOf(elem_id)!=-1))
The problem is that the alerted id of the control isn't the exact id that i've written in the

webuser control, but a string that seems to concatenate all the parent html controls of the

control that i am searching for, ex. if the control that i'm searching for is
<asp:Textbox id="txtName" runat="server"/> and it is nested inside a groupbox
<groupbox:Group id="grp_1" runat="server"/> then the alerted id isn't TXTNAME but GRP_1_TXTNAME etc.
Two questions then:
1. Is the search in the "for statement" hierarchicly ordered? I mean, if i have another <asp:textbox id="txtName2" runat="server"/> inside the groupbox, will the first only be rendered if i put a break after the "if statement"?
2. Is there a way to get the exact id name of the controls without the "indexOf"?

Thanks in advance!

12-15-2009, 02:45 PM
Not sure I get it exactly, but


returns "TXTNAME" if elem[i].id is GRP_1_TXTNAME

or it might be "_TXTNAME". Let me check that...

Edit - yes it is, so


12-15-2009, 03:43 PM
For javascript it does not matter the client-side code, but the HTML generated code. Show us the HTML generated code.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum