Solved

Obtaining the treenode value with Javascript

Posted on 2008-06-12
3
1,127 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
  • 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How do I get the unique ID after insert? 87 92
Image(2) 3 29
dynamic menu in asp.net c# 11 31
Adjust the position 3 14
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!
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now