Solved

Obtaining the treenode value with Javascript

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

Industry Leaders: 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

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 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