This is a migrated thread and some comments may be shown as answers.

Basic Razor Question

1 Answer 63 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 20 Jun 2012, 10:39 PM
I'm trying to use a Treeview control in a Razor Host script within DNN 6.2.  I'm not sure what the basics are in that regard.  Here is what I have so far.  Am I even close?  Are there existing Razor examples I could look at?  Thanks for any help you can provide.

@using DotNetNuke.Entities.Tabs
@using DotNetNuke.Web.UI.WebControls
@{ 
    var tabs = TabController.GetTabsByParent(2938, Dnn.Portal.PortalId);
    var tree = new DnnTreeView();
    tree.DataSource = tabs;
    tree.DataTextField = "TabName";
    tree.DataValueField = "TabId";
    tree.DataFieldParentID = "ParentId";
    tree.DataBind();
    System.IO.StringWriter tw = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
}
@{
    tree.RenderControl(hw); 
}

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 25 Jun 2012, 05:23 PM
Hello David,

The TreeView is a Web Forms control and so it can be used only in a Web Forms View(ASPX). In order to create it in a View that uses the Razor view engine, you could try to render it in a partial ASPX View. 

Kind regards,
Daniel
the Telerik team
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TreeView
Asked by
David
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or