473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.all;

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 17820
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.all;


var oCollection = pnlProperties.childNodes;

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.childNodes 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.all;


var oCollection = pnlProperties.childNodes;

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.childNodes 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 getElementsByTagName("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.childNodes[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.childNodes 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 getElementsByTagName("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.all;


The all collection does not only contain the child elements but all
descendant elements thus you would need
var oCollection = pnlProperties.getElementsByTagName('*');
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
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...
11
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...
2
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...
2
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...
7
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. ...
10
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...
1
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...
5
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...
11
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.