muthu
muthu

Reputation: 87

asp.net tree view selectd node value using javascript

hi i am using a treeview control in my page i am binding the treeview with the datatable

i need to use javascript to get the selected node value on the tree in a button click. how to do this

Upvotes: 1

Views: 3778

Answers (1)

smercer
smercer

Reputation: 916

When you bind your tree, use the navigateURL property of each node to call a JavaScript function.

When you bind:

newNode.NavigateUrl = "javascript:clickNode(this, '" + someObject.ID.ToString() + "');

On the client:

var selectedNode;
var selectedValue;

function clickNode(sender, id)
{         

    selectedNode = sender;
    selectedValue = id;

    //do other stuff here       
}    

Upvotes: 2

Related Questions