Solved

TreeView OnTreeNodeCheckChanged problem

Posted on 2008-06-12
1
2,865 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

773 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