You can create an extension method that uses recursion to create the <ul> and <li> elements to display the folder hierarchy
public static class FolderTreeExtensions { public static MvcHtmlString FolderTree(this HtmlHelper helper, TreeViewFolder folder) { return MvcHtmlString.Create(TreeLeaf(folder)); }
Then in your controller, initialize and populate the TreeViewFolder instance, and in the view
@model TreeViewFolder .... @Html.FolderTree(Model)
Then create items to suit your requirements.
Note: either add a using statement to the view, or add a link to the <namespaces> web.config section
source share