Good Morning All,
Need help in setting the backcolor of a selected node in asp.net 2.0' s treeview control, without postback.
This is what I did:
1.Populated the treeview control using a collection(of nodes).
2.For each TreeNode created , set the NavigateUrl property,
child.NavigateUrl = "javascript:SelectNode(this," + node.NodeId +")";
3.Javascript:
var prevNode= null;
function SelectNode(currentNode, nodeId)
{
if(prevNode!=null)
prevNode.className='';
currentNode.className='selected';
prevNode= currentNode;
}
Question / Problem:
1.alert(currentNode) gives object, but color dont change.
2.alert(currentNode.id) gives undefined even though the viewsource shows something like this:
<table cellpadding="0" cellspacing="0" style="border-width:0;">
<tr>
<td><div style="width:10px;height:1px"><img src="/WebResource.axd?d=P4RU-hSsdH2kOfIwJeYucpQuKE03aRBqIWkkbK1ZiYE1&t=633217587889533860" alt="" /></div></td><td><img src="/WebResource.axd?d=P4RU-hSsdH2kOfIwJeYuci_CkJj3oPaIAvyG7pay0L01&t=633217587889533860" alt="" /></td><td style="white-space:nowrap;padding:0px 5px 0px 5px;"><a href="javascript:SelectNode(this,641);" id="treeviewDomianst7" style="text-decoration:none;">xxxxxxxx</a></td>
</tr>
</table>
What's wrong?? Why not alert(currentNode.id) return the correct id (treeviewDomianst7) ??
Appreciate any solution (without postback)
thanks.