473,791 Members | 3,122 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Howto get child controls collection in Jscript (withous using object.all)?

Let's say that I have panel control which is container control, and I need
to access every child control inside panel control from JScript. I have this
line of JS code:
var oCollection = pnlProperties.a ll;

And then I browse through te collection with for loop doing what I need
etc..

Anyway, this line of code seems to be huge problem for Mozilla browser,
becouse it is not supported by W3C standard (document.all is not
compatibile with standard).

Is there any W3C compatibile method which returns collection of child
controls within parent control? Or somethign that could help me to collect
this collection manually... I failed to find some...

I have 7 algorithms based on this structure so I really have to keep this
collection or change 7 algorithms not to work with this collection..

Thanx!
Jul 27 '05 #1
5 17855
Mateo wrote:
Let's say that I have panel control which is container control, and I need
to access every child control inside panel control from JScript. I have this
line of JS code:
var oCollection = pnlProperties.a ll;


var oCollection = pnlProperties.c hildNodes;

returns a NodeList which you can use to loop
Jul 27 '05 #2
Ok... but...

I have panel control (asp.net web form control) and I have 6 check box and
list
box controls contained inside panel control...

pnlProperties.c hildNodes return me collection with 2 child controls????
Why....

I tried with non-web form controls (standard HTML controls) and I get the
similar result....
I don't understand this:(
"Robert" <ro****@noreply .x> wrote in message
news:42******** *************** @news.xs4all.nl ...
Mateo wrote:
Let's say that I have panel control which is container control, and I need to access every child control inside panel control from JScript. I have this line of JS code:
var oCollection = pnlProperties.a ll;


var oCollection = pnlProperties.c hildNodes;

returns a NodeList which you can use to loop

Jul 27 '05 #3
Mateo wrote:
I have panel control (asp.net web form control) and I have 6 check box and
list
box controls contained inside panel control...

pnlProperties.c hildNodes return me collection with 2 child controls????
Why....

I tried with non-web form controls (standard HTML controls) and I get the
similar result....
I don't understand this:(


Well, I am just guessing, but maybe your .net form controls creates 2
child nodes which are just containers themselves used for layour
purposes. You could check this by viewing your HTML.

So what you probably want is not getting a collection of your child
nodes, but all descendants.
Perhaps getElementsByTa gName("input") returns the list that you need.
Or you need to loop the childNodes too when appropriate.
Jul 27 '05 #4
Thx man!

This works...

for exmaple : parentControl.c hildNodes[0].childNodes[1].id
So I wrote recursive algorithm which walks through tree, and I get complete
collection of child nodes....
Thx 4 giving me idea!

"Robert" <ro****@noreply .x> wrote in message
news:42******** *************** @news.xs4all.nl ...
Mateo wrote:
I have panel control (asp.net web form control) and I have 6 check box and list
box controls contained inside panel control...

pnlProperties.c hildNodes return me collection with 2 child controls????
Why....

I tried with non-web form controls (standard HTML controls) and I get the similar result....
I don't understand this:(


Well, I am just guessing, but maybe your .net form controls creates 2
child nodes which are just containers themselves used for layour
purposes. You could check this by viewing your HTML.

So what you probably want is not getting a collection of your child
nodes, but all descendants.
Perhaps getElementsByTa gName("input") returns the list that you need.
Or you need to loop the childNodes too when appropriate.

Jul 27 '05 #5


Mateo wrote:
Let's say that I have panel control which is container control, and I need
to access every child control inside panel control from JScript. I have this
line of JS code:
var oCollection = pnlProperties.a ll;


The all collection does not only contain the child elements but all
descendant elements thus you would need
var oCollection = pnlProperties.g etElementsByTag Name('*');
in a W3C DOM compliant script to have the same result.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 27 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1269
by: wASP | last post by:
Hi, I was under the impression that, when ASP rendered a page, it recursively traversed the hierarchy, executing all controls in each ControlCollection of every control in that hierarchy. I tried adding a Button control to a TextBox ControlCollection, and it didn't execute. When I add the control to the Placeholder ControlCollection (after the TextBox control is added), it executes without any problem:
11
18710
by: Pavils Jurjans | last post by:
Hello, There's some confusion about the purpose and difference between these handy classes... First, both of them are holding number of key - value pairs, right? Then, I see that there may be some difference in terms of data types allowed for keys and values, perhaps? I read the following in MSDN about "CollectionBase" class and
2
1850
by: Harry | last post by:
Hello, I have a composite WebControl that I'm dynamically instantiating at runtime using Reflection. When I create a new instance of my control I immediately iterate through it's child control collection (it has about 4 child controls). The problem is none of these controls are loaded or accessible when I create the instance since, I believe, they are created by the server at a later point in time. How could I force my composite control...
2
2227
by: Juan Romero | last post by:
Hey guys, I am working on a web custom control that basically draws a table (ASP Table) with a few child controls in the cells. I have a command button inside one of these cells. The problem I am running into is that I cannot get the click event of this object handled. I have tried wiring the event with "AddHandler" among other things and that seems not to work neither.
7
2017
by: Neo Geshel | last post by:
Greetings. I have a serious problem. I have multiple sets of tables, several of which are chained more than two tables deep. That is, I have a parent, a child, and a great-grandchild table. Currently, I am allowing the parent to be edited by itself. In order to get to a child table, a user needs to select a specific parent table ID. I have set this up using panels, and putting a drop-down list in the first panel, with its contents...
10
4030
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
1
1346
by: paul.hester | last post by:
Hi all, What is the recommended way to add child controls *around* existing child controls in the CreateChildControls method (e.g. table, row and cell controls for layout purposes)? Is the best way to keep a reference to the existing child controls, clear the Controls collection and then re-add everything along with the layout controls, or insert the layout controls around the existing controls in the existing Controls collection?
5
2246
by: Earl | last post by:
I need to call a method on an owned child form, and am wondering if the best way of doing this is to capture the Closing event of the form that passes control back to the form where I have the method. The structure is like so: frmMain (MDI, runs on app start) calls frmB (MDI child), which in turn calls frmC (MDI child), which in turn calls frmD (MDI child). frmMain and frmB remain open while frmC and frmD are shown.
11
4239
by: dhtml | last post by:
(originally mis-posted on m.p.s.jscript...) I've just closed all windows in Firefox and its using 244MB of memory. I have no idea why. I had GMail open, a page from unicode, the CLJ FAQ. I've noticed that createElement leaks. It's obvious with form controls because the form keeps the control name as a property. Example:
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10147
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9987
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9023
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5424
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4100
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.