Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Obtaining the treenode value with Javascript

Posted on 2008-06-12
3
Medium Priority
?
1,152 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 375 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

688 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