views:

74

answers:

1

Here is my scenario and I would like to ask your opinion on which control is best to use. I am using C#, ASP.net 2.0.

I am required to create a structure that resembles a tree. The user will start with something and then will add nodes to it. Every node is a structure by itself, so a user should be presented with an option to create a new node type or use an existing type of a node.

The obvious choice here seems TreeView. However, I have few concerns: 1) I was asked to minimize the number of trips back to the web server, and I am not sure how this would work with TreeView.

2) If I do end up using TreeView, creating a new node type (currently it is a .ascx (user control)) could be tricky to deal with, as I would need to open a new window and return node id and name to the parent page (which contains TreeView ) upon node type creation and seemlessly update it.

Any recommendations?

+1  A: 

You may want to look into JQuery's Treeview

http://docs.jquery.com/Plugins/Treeview/treeview#options

this way, you can update the treeview on the client side, and when the user gets everything working as needed, then submit the tree state.

JQuery for .Net http://jquerydotnet.codeplex.com/

madcolor
Can I create nodes on the server with it? What I need specifically is being able to create a new type of a node (with existing server control), then pass id and name t o the page containing TreeView, then update the TreeView on the client side.
gnomixa
When you say "create nodes on the server", what exactly does that mean? In the end, you should only be concerned with passing a userid and state of the nodes as they set them.
madcolor
Every node will trigger a new window open, with the sever GridView where users can create a new node type, save it to the database. Once this window is closed I should be able to pass Node Type Id and Name to the TreeView.
gnomixa
What I am concerned with is that the pop up window component is server based and TreeView is client (or I need it to be mostly client side manipulated), I am mostly a server side programmer and not sure how this scenario will play out
gnomixa
I don't really want to do everything on the client, just the Tree manipulation. Hope I have explained this clearly.
gnomixa
Think of a node type as part of my structure, not just a TreeView Node. Every node is a little structure in the database, which is entered through Gridview (there are several detail rows, but that's just particulars).
gnomixa
But at the end I need to be able to pass variables from the server side control to Javascript, so I can update the TreeView.
gnomixa
This is all doable.. I think you're going to have to rely more on the client side than you seem to want to. It sounds to me like you have all of the pieces, but just need to know how to put them together. Something I don't have the time to explain. I can delete my answer if you'd like.
madcolor
no you can leave it. It may give me an idea. I am not sure what you mean by relying more on the client, as you don't have time to explain, I won't ask. Thanks anyway.
gnomixa
I guess what I"m saying is this.. If you can, you want to grab data for the grid, spit it out, then let the user do all configuration on the client-side, then return back to the server. JQuery can definitely help you make that happen.
madcolor
Oh yes, in the big picture I will definetly be doing that. But in the midst of this process I need to write some data to the database, and return stuff to the client TreeView. So essentially, I will have to do a mix of things, I am at this point unclear how to do this elegantly.
gnomixa
Well.. Ajax is the elegant answer for that. Have you gone that route yet? Are you able to add the AjaxToolkit? If not, then you'll be using XMLHttpRequest and JSON.
madcolor
Yes, i have Ajax Tool Kit. Great thanks! So essentially I should look into TreeView with Ajax? Thanks!
gnomixa
The TreeView is not in the kit though, so I will have to research how this is going to be used. Is callback usage an alternative here?
gnomixa
http://steveorr.net/articles/Ajax.aspxis that what you mean by using Ajax? I am slightly confused at the abundance of terms:)
gnomixa
Yeah, AJAX is going to reduce the load of each request\response beyond the initial request, but you'll end up with potentially more requests if you're going to "I need to write some data to the database, and return stuff to the client TreeView" a lot. Implementing Ajax in a tree isn't trivial tho.
madcolor
Wanted to add this link as well.. http://jquerydotnet.codeplex.com/JQuery for .Net.
madcolor