To accomplish the task you need to create two javascript objects:
- one for checking the dragging state
- one for saving information about the previously highlighted node
Also, when hooking the BeforeClientDrag client-side event you have to set the dragging mode to true (respectively when subscribing to the BeforeClientDrop event you modify the dragging mode to false).
Finally, in the BeforeClientHighlight event handler simply check the drag state - if it is on, set a custom background color for the hovered node and clear the background color for the previously highlighted node.
Below is a code snippet representing the actions illustrated beforehand:
Example:
| ASPX |
Copy Code |
|
<script language="javascript"> var dragging = false; var previousNode = null; function HandleDrag(node) { dragging = true; } function HandleDrop(node) { dragging = false; } function ProcessHighlight(node) { if (dragging) { var current = document.getElementById(node.ClientID); current.style.backgroundColor = "Gray"; if (previousNode) { previousNode.style.backgroundColor = ""; } previousNode = current; } } </script> <rad:RadTreeView id="RadTreeView1" runat="server" DragAndDrop="True" BeforeClientDrag="HandleDrag" BeforeClientDrop="HandleDrop" .../> <rad:RadTreeView id="RadTreeView2" runat="server" DragAndDrop="True" BeforeClientHighlight="ProcessHighlight" .../> |