Taking inspiration from @gaynorvader and the answer located here, I came up with the following solution that looks like this:

with HTML like this
(in the below code the ASP.NET panel and tree view markup is rendered as real HTML elements in the browser):
<div id="container" style="border:1px solid;">
<div id="top" style="background-color:red;height:20px;opacity:0.4;filter:alpha(opacity=40);"></div>
<asp:Panel ID="panel"
Style="overflow:auto;"
runat="server"
Width="100%" Height="100px">
<cc1:ASTreeView ID="treeView1"
OnNodeDragAndDropStartScript="startDrag()"
OnNodeDragAndDropCompletedScript="completedDragHandler()" ... />
</asp:Panel>
<div id="bottom" style="background-color:red;height:20px;opacity:0.4;filter:alpha(opacity=40);"></div>
</div>
What I've done here is created two div elements at the top and bottom edge of the panel which contains the TreeView (with all three elements contained within a 'container' div). The intent of the two div elements is that they can initiate the scrolling when the mouse cursor enters them while dragging and dropping.
Then, In the HTML for the TreeView, I've associated two JavaScript functions with the TreeView's drag start event (OnNodeDragAndDropStartScript
) and it's drag completed event (OnNodeDragAndDropCompletedScript
):
function startDrag()
{
$("#top").hover(function () {
$("#MainContent_panel").animate({ scrollTop: 0 }, "slow");
});
$("#bottom").hover(function () {
$("#MainContent_panel").animate({ scrollTop: $(window).scrollTop() + $(window).height() }, "slow");
});
}
function completedDragHandler()
{
$("#top").off();
$("#bottom").off();
}
In the drag start event handler function (startDrag
), I've used JQuery to add an event handler function to the 'Hover' event. This function is invoked whenever the mouse cursor enters the div element.
To initiate the scroll, the JQuery animate
API is invoked on the panel containing the TreeView, with arguments to tell it to scroll upwards slowly.
In JQuery, there is no argument to scroll downwards, and so taking inspiration from the answer here, I was able to implement a downward scroll.
Additionally, I used the JQuery off()
function to remove the event handlers when the drag event has completed (OnNodeDragAndDropCompletedScript
).