Solved

Obtaining the treenode value with Javascript

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Entity Framework Error: 'The user instance login flag is not supported' 12 32
Jquey and footrable 2 33
Error on Add method 1 36
Exit the loop 4 22
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

943 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

17 Experts available now in Live!

Get 1:1 Help Now