How to get ClientID of a TreeNode in a TreeView based on one of its rendered attributes, for example, its title attribute (In my case it’s unique) ,using either Server-Side or Client-Side code?
I go with this code, but it doesn’t work, any suggestion?
// Retrieves TreeNode ClientID. function GetTreeNodeID(nodeTitle) { var treeNodes = document.getElementById('tvMenu').childNodes; var treeLinks; for(var i=0 ; i<treeNodes.length ; i++) { treeLinks = treeNodes[i].getElementsByTagName('a'); for(var j=0 ; j<treeLinks.length ; j++) { if(nodeTitle == treeLinks[j].title && treeLinks[j].title != ''); { alert('Par: ' + nodeTitle); alert('Title: ' + treeLinks[j].title); return treeLinks[j].id; } } } }
The above code that is mentioned with the question always returns the id of root node, any suggestion?
innerText or innerHtml or textContent ? Wich browser do you use ?
Look here for a sample code.