Solved

TreeView OnTreeNodeCheckChanged problem

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
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…

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

13 Experts available now in Live!

Get 1:1 Help Now