how to?
I tried AutoPostback=false, but clicking on the node still posts the page back. Any ideas?
how to?
I tried AutoPostback=false, but clicking on the node still posts the page back. Any ideas?
where on the control's declaration did you put the AutoPostback=false? Can you maybe edit to question to include your code so we can help you out?
The default setting for EnableClientScript is true, so by default, expanding and collapsing of nodes should be happening client side. Note the remarks for that property though (Emphasis mine):
Use the EnableClientScript property to specify whether the TreeView control renders client-side script on compatible browsers to handle expanding and collapsing events. When this property is set to true, compatible browsers execute the code to expand and collapse nodes on the client. The tree node data must be known in advance for the client-side script to work. Using client script prevents a post back to the server each time a node is expanded or collapsed.
Things to check:
If you can't have all the data available, then you should ensure that you are setting PopulateOnDemand, PopulateNodesFromClient and TreeNodePopulate correctly.
Response to comments
Yes, there's no reason why you can't do what you're attempting to do with a tree view control - indeed, it should do most of this for you - unless you aren't supplying the whole tree up front, in which case you'll need to supply the methods that will populate the nodes through PopulateNodesFromClient and TreeNodePopulate, assuming the browser is recognised correctly (those previous links have examples of both with and without postbacks).
The jQuery Tree View plugins will probably be more flexible (I've not used them so I wouldn't know - I have used the TreeView control we're discussing, but was getting the features "for free" because I only had a small tree, and was supplying all the data up front), but will require a bit more work to set up:
3 may or may not be the kicker for you - in everything we do, we try to use JavaScript to enhance functionality, not provide the functionality - as the jQuery library is all client side, if the browser doesn't support JavaScript, your jQuery TreeView control won't appear, and you'll possibly be losing a key navigational element, whereas a Server control like the ASP.NET TreeView control will notice that JavaScript isn't supported and resolve this for you by falling back to a server based (i.e. post-back) version of the control.
You should also remember that jQuery isn't a Microsoft thing (although they do now support it), and has been around for quite some time, and as a client side offering, it works independantly of the server technology - MS give us a number of "server" controls within the ASP.NET framework that we can use if we want to, and doing so can make our lives easier (usually in the short term anyway), but we don't have to - a prime example is the recently released ASP.NET MVC framework, which is a different way of building web applications on IIS using the .NET stack - but generally without the server controls.
The asp.net treeview does not support this functionality,
try obout treeview: http://www.obout.com/t2/index.aspx
It does load the nodes without reloading the whole tree.
A way forward.....
The automatic select action for each node is SelectExpand, the "Select" part of this enum is interpreted as "I've selected something and need to postback". To just "Expand" the node without causing a postback:
TreeView1.Nodes(0).SelectAction = TreeNodeSelectAction.Expand