Solved

TreeView OnTreeNodeCheckChanged problem

Posted on 2008-06-12
1
2,851 Views
Last Modified: 2013-11-26
I have a problem, it's something that shouldn't happen, I have a treeview with a bunch of branches, I have added the OnTreeNodeCheckChanged event to the tree, when that happens it will Check or UnCheck all the Child nodes, when I click on the CheckBox nothing happens, but when I select the node I just changed the event gets fired, Shouldn't the OnSelectedNodeChanged be fired by a change in Selection? Why is it not firing with my Check Change?

Please help.

Thanks,
0
Comment
Question by:victorbello
1 Comment
 
LVL 14

Accepted Solution

by:
Dustin Hopkins earned 500 total points
ID: 21776526
It is calling the event, but that event doesn't cause a post back and won't reload the control, which selected node change does do. So a work around is to use javascript to call the postback. Like this:
add the onclick event to your treeview:
<asp:TreeView ID="TreeView1" onClick="javascript:postbackOnCheck(event);" runat="server"  ShowCheckBoxes="All">

Then add this javascript function:

 <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

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 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

22 Experts available now in Live!

Get 1:1 Help Now