Thursday, November 10, 2016

How to get ASP Treeview selected node value using Javascript

How to get ASP Treeview selected node value using Javascript



  function GetSelectedTreeNode() {
        debugger;
        var treeViewData = window["<%=trviewFolders.ClientID%>" + "_Data"];
        if (treeViewData.selectedNodeID.value != "") {
            var selectedNode = document.getElementById(treeViewData.selectedNodeID.value);
            var value = selectedNode.href.substring(selectedNode.href.indexOf(",") + 3, selectedNode.href.length - 2);
            var text = selectedNode.innerHTML;
             alert("Display name: " + text + "\r\n" + "NodeValue: " + value);
           // gloSelectedNodeVal = text;
        }
        else {
          // alert("No node selected.")
        }
        return false;

    }

No comments:

Post a Comment