Solved

TreeView OnTreeNodeCheckChanged problem

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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

623 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