views:

817

answers:

4

What would be the advisable thing to do to maximize the performance while using TreeView?

By maximize the performance, i mean minimize the number of trips between client to server, ie postbacks.

Would that mean then, that most of my Business logic will sit in the Javascript? What would be the compromise here?

I am talking about ASP.net TreeView server control

A: 

development overhead - you will have to maintain your business logic in both javascript and code behind.

reduced client performance would also be a concern if the script is big.

FlyinFish
I guess the separation of Business Login from Presentation layer is impossible then?
gnomixa
you could have separate javascript files to handle business logic,think the javascript as a different agent, consisting its own PAC hierarchy.Or alternatively, you could generate javascript validation from the code behind.
FlyinFish
+1  A: 

First, decide where you want to put your programming logic: for speed, it's better to use some other tree view control (that doesn't use table layout) and javascript framework to handle click events. I recommend using plain old ashx handler files for AJAX communication, they have less overhead than aspx and calling page methods. AJAX calls and results must contain only JSON or XML formatted data, not HTML.

On the oher side, RAD tool like VS and TreeView control offers quick production of web application, but of course with some penalties: you need to go back to server to handle every click/select event, which draws issues with whole page life cycle processing and huge amount of data transfer for ajax calls (ViewState along with HTML are transferred from server to client for every ajax event).

But if you want to stick with TreeView, i recommend:
- CSS Friendly Control Adapter: they greatly reduce size of generated html (in my case, from 100kb to 20kb of html) and replace table layout with ul/li elements
- Wrap TreeView inside ASP.NET AJAX UpdatePanel, but just treeview, and use conditional updates of panel. Don't be afraid to use several updatepanels
- keep ViewState minimal

Hrvoje
Actually according to this http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspxUpdatePanel is not compatible with TreeView
gnomixa
I have Treeview in UpdatePanel, but had to do some tricks. Please let me know if you want me to post here how i did it!
Hrvoje
No its ok, if MS says they don't support it inside UpdatePanel, I am not going to use it there.
gnomixa
Actually, according to MS, TreeView was implemented with built-in Callback (http://msdn.microsoft.com/en-us/library/e8z5184w.aspx)it says there that if you set certain properties properly, the tree will load nodes inside callback w/o posting back the whole page.
gnomixa
Then again, i haven't tried it yet. It might not do what I have in mind.
gnomixa
There is workaround to get TreeView working inside UpdatePanel!
Hrvoje
A: 

Hrvoje,

Please provide the tricks as i urgenlty need it..

A: 

Hello gnomixa,

Maybe you could take a look at the ASTreeView which has full functionality including drag&drop, ajax loading, context menu, and the performance is great!

check out the demo:

http://www.geekees.com

Weijie JIN