Adding new child node to TreeView, then select it

2 posts, 0 answers
  1. Robert
    Robert avatar
    1 posts
    Member since:
    Jan 2014

    Posted 30 Jan 2014 Link to this post

    Hello all,

    I am trying to bind a TreeView to a folder on the server - and I've got it working. The issue is that I would like to give users the ability to create their own folders. Through a javascript prompt, I'm able to get the new folder's name, and submit it via Ajax to a web service that creates the folder on the file system.

    Where I'm stuck is adding the new node (folder) to the TreeView, and having it display. I got the javascript working, but sometimes it doesn't mark the new node as a directory (with a "plus" icon) - and sometimes it does. It's inconsistent (see attached image of a newly inserted node). Now if I refresh the page, the new folder appears correctly (with the "plus" icon).

    I realize I'm binding to a physical directory on the server side, and then dynamically inserting a node on the client side - so maybe this is part of the problem. I'm just looking for a way to allow the user to create a folder, then have it added to the TreeView and selected (highlighted), with the ability to continue adding subfolders.

    I'm okay with a page refresh - but so far I haven't been able to find a way to select a child node on the page load (I can select a top-level "root" folder, but it doesn't expand the tree to select the child node.

    You can download mt test page here:

    Thanks for any assistance!

  2. Hristo Valyavicharski
    Hristo Valyavicharski avatar
    975 posts

    Posted 04 Feb 2014 Link to this post

    Hi Robert,

    Why don't you use the File Explorer control? It has a built-in support for adding/editing/removing files and folders.

    Hristo Valyavicharski
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top