Technorati Tags: ASP.NET,TreeView,jQuery When we expand TreeView node JavaScript function TreeView_ToggleNode gets executed (it’s part of the TreeView control itself). So we will “override” this function and add our own functionality to perform scroll to the expanded node. To find source code of TreeView_ToggleNode function you can use IE Developer Toolbar or Firebug. I removed some code from this function that I don’t need to make it shorter. Here is the result. Everything should be pretty self ......
Technorati Tags: ASP.NET,TreeView,jQuery If we have TreeView inside of the div with the fixed width and height we want selected node to be visible after postback. Here is small JavaScript function that does this (you don’t have to use jQuery as I did to get the result): 1: function ScrollToSelectedNode() 2: { 3: //* get selected node id 4: //* 'tvwScrollTo' - is our tree view id 5: var selectedNodeID = $('#<%=tvwScrollTo.ClientID %>_SelectedNode').val(); 6: 7: if (selectedNodeID != '') 8: { ......
Technorati Tags: TreeView,ASP.NET,JavaScript TreeViewClientID_Data.selec... where TreeViewClientID_Data is the name of the TreeView javascript object that has “selectedNodeID” property. We can easily load this object and get selected node id like this: 1: Sys.WebForms.PageRequestMan... 2: 3: function EndLoadedHandler(sender, args) 4: { 5: //* make sure that object is fully loaded 6: var data = eval('<%=tvwScrollTo.Cli... %>_Data'); ......