Tutorial :replacement of asp:Treeview for ASP.NET MVC application


I thus far worked with asp:Treeview for all my dynamic menus for my web applications..

Any suitable replacement of it in an asp.net mvc web application...

  • Any HTML helper that can perform like Treeview for me?


I would use jQuery based plugin. Like this one.


In my Mvc Controls Toolkit I have a server control based on the jQuery TreView. However, I allow node editing, insertion ov new nodes, and moving sub-tree into another location by dragging it with the mouse. All changes are reflected Automatically on data structures on the server side when the view is posted. Moreover all nodes are templated and the same tree can have different type of nodes. Give a look here: http://mvccontrolstoolkit.codeplex.com/wikipage?title=TreeView


As Arnis said, using Jquery Pluggin, it is so easy! I do it by encapsulating the code and html in a Partial View as a UserControl. You can do it by a recursive logic:

@helper ShowTree(TreeItem item, IEnumerable<TreeItem> tree)      {            var childs = folders.Where(g => g.ParentId == item.Id);          if (childs.Count() == 0)          {      <text>      <li class="last"><span class="folder">@item.Title</span></li>      </text>          }          else          {      <text>      <li class="expandable">          <div class="hitarea expandable-hitarea">          </div>          <span class="folder">@item.Title</span>          <ul style="display: none;">              @{foreach (var child in childs)                {                  @ShowTree(child, folders)                }              }          </ul>      </li>      </text>          }  }  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »