M
Mark Rae
I've bound the tree to an XML datasource.
??? Why have you done that...??? The whole point of the way this works is
precisely *not* to populate the TreeView automatically by databinding...
Like I said, you need to add each node to the TreeView programatically. By
all means use an XML datasource if you like, but walk through its contents
in code, don't set it as the TreeView's datasource...
I don't want the page to refresh when the user clicks on any of the nodes
that have children (I just want the node to expand without a postback).
I was setting the css style of the node when the treeviews selected node
was changed (i.e. parsing through the nodes and if one is selected then
settting the CSS class). This would presumably cause a postback even if I
have set TreeNodeSelectedAction.Expand for each node so this is not the
right way to do it.
No. You only set TreeNodeSelectedAction.Expand for nodes which have
children. Obviously, you don't set a NavigateURL property for these nodes...
So, trying to achieve this via pure css, (and my CSS knowledge is not
great but ...) when a treenode is selected, does it's css class become
'.treeNodeCssClass.on'?
No, it doesn't.
Or does is need to be '#treenodeId.on' ? ( - that can't be the right way
as I'd have to set up a CSS class for every node that could be selected
based on its ID wouldn't I?)
Exactly! You need only as many CSS classes as there are different formatting
styles...