0

I've a TreeView that displays hierarchical data, while I select a TreeNode, I generate a series of links that map the path from selected node till root node

Say: Root Node --> ChildNode --> SelectedNode

What I need is, while clicking any of these links, select required node in TreeView?

I know that selecting a TreeNode is done through ClientSide using this code:

javascript:__doPostBack(TreeView.ClientID,TreeNodeValuePath) 

and

TreeView_SelectNode(TreeView.ClientID_Data, this,TreeNode.ClientID)

Ex:

    <a style="border-style: none; font-size: 1em;" id="tvMenut1" title="Created On: 1/28/2009 9:50:06 AM" onclick="TreeView_SelectNode(tvMenu_Data, this,'tvMenut1');" href="javascript:__doPostBack('tvMenu','s1\\720,63')" class="tvMenu_0 treenodeParent tvMenu_3">
Etravel2000

My problem is to get TreeNode.ClientID?

Any suggestion? FYI: this page is an AJAX-Enabled page.

4 Answers 4

0

TreeNode.ClientID as int the ASP.Net control ClientID?

If so, drop this wherever you're trying to pass it: <%= TreeNode.ClientID %>

0

There is no a TreeNode.ClinetID property for TreeNode object.

0

You can get ClientID of a TreeNode using the following method. You can change which parameter you will use to get a node based on it.

    function GetTreeNodeID(nodeTooltip)
    {
        var tree = document.getElementById(TreeView.ClientID); // Change TreeView ClientID.
        var treeLink =  tree.getElementsByTagName('A');    

        for(var element in treeLink)
            if((nodeTooltip == treeLink[element].title) && (treeLink[element].title != ""))                      
                return treeLink[element].id;
    }

Then use this code for each TreeNode in TreeView.

spanPath.InnerHtml += "<a href=\"javascript:__doPostBack('tvMenu','" + targetNode.ValuePath + "')\" onclick=\"TreeView_SelectNode(tvMenu_Data, this, GetTreeNodeID('" + targetNode.ToolTip + "'));\">" + targetNode.Text + "</a>&nbsp;&nbsp;-->&nbsp;&nbsp;";

While you select a node from spanPath, it will be selected in TreeView.

0

Its helpfull for geting node ID from client side.

http://pushpontech.wordpress.com/2007/06/14/getting-treenode-values-on-the-client-side-with-javascript

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.