Solved

Obtaining the treenode value with Javascript

Posted on 2008-06-12
3
1,149 Views
Last Modified: 2012-05-05
I'm using a treeview control and storing an 'id' number as the value of each treenode.  I'm trying to use Javascript to loop through all the tree nodes to find the ones that are 'checked' and pull the 'value' or ID number in order to populate another control on the page.  Can anyone tell me how to do this?  We're using VS2008.

Thanks!
0
Comment
Question by:trebems
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
Dustin Hopkins earned 125 total points
ID: 21783246
This code is setup to capture teh event and do a postback, i;m sure you can edit it to get the value or text.
Add this to teh treeview:

add the onclick event to your treeview:
<asp:TreeView ID="TreeView1" onClick="javascript:postbackOnCheck(event);" runat="server"  ShowCheckBoxes="All">

<script type="text/javascript" language="javascript">
 
function postbackOnCheck(e) 
{ 
var isNav = (window.navigator.appName.toLowerCase().indexOf("netscape")>=0); 
var o; 
if (isNav && e != null) 
o = e.target; 
else 
o = window.event.srcElement; 
if (o.tagName == 'INPUT' && o.type == 'checkbox' 
&& o.name != null && o.name.indexOf('CheckBox') > -1) 
__doPostBack("",""); 
} 
</script>

Open in new window

0
 

Author Closing Comment

by:trebems
ID: 31466704
Thanks!
0
 

Author Comment

by:trebems
ID: 21815946
Thanks!
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question