Home - Forums-.NET - FlyTreeView (ASP.NET) - OnPopulateNodes needs ViewState enabled?

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

OnPopulateNodes needs ViewState enabled?
Link Posted: 28-Oct-2006 08:26
I was running into an issue where my serverside OnPopulateNodes method was getting called, but was not passing any arguments.  As a result, the nodes argument was null.  I traced it back to the fact that I had set EnableViewState=\"false\" for the page.  

This seems strange to me, but I can repeat it on any node, by setting the EnableViewState=\"false\" for either the node or the page.  Is this something that is totally necessary or am I missing something.  I have a page where I have a lot data in the tree and don't want the viewstate to contain all that data (for performance reasons).  However, I also need the populate on demand to work on a few nodes in this tree.  The whole process works great with ViewState enabled, but I don't want that.  

Thanks,

Jamey
Link Posted: 28-Oct-2006 10:17
I'll try to explain the things.

FlyTreeView uses callbacks to populate nodes on demand. All treeview nodes are stored in ViewState. This is the way treeview restores its nodes during postback and callback page loads. So if you disable it - Nodes collection will be empty during callbacks and postbacks.  

During callback, flytreeview.Nodes collection should contain node that you expanded. This is the way one can determine what node was expanded and what child nodes should be added (populated).

Possible workaround for this is to store treeview Nodes collection in the Session collection. And bring back these stored nodes to treeview.Nodes every page load (probably OnInit stage will be ok).

Another option is to enable ViewState.

I should also say few words about huge viewstate size workarounds. Currently there are several techniques available on the web.
For example it is possible to store viewstate in a persistent medium.
Another solution (9Rays uses for its own web site) is an ASP.NET http compression module that uses gzip/deflate compression to compress all the ASP.NET rendered output. This is generally a very good approach because it dramatically reduces page size (by a factor of about ten) and speeds up page load.