Display a view in _Layout.cshtml?

I have followed this tutorial to generate a dynamic list menu http://dotnetawesome.blogspot.se/2014/06/how-to-create-treeview-with-database-data-mvc4-aspnet.html

This is the view

@model List<Project.Models.Treeview>

    ViewBag.Title = "Simple";

<h2>Simple Treeview from Database Data</h2>
<div style="border:solid 1px black; padding:10px; background-color:#FAFAFA">
    <div class="treeview">
        @if (Model != null && Model.Count() > 0)
                @Treeview.GetTreeView(Model, Model.FirstOrDefault().ParentCategoryID)

@* Here We need some Jquery code for make this treeview collapsible *@
@section Scripts{
            $(document).ready(function () {
                $(".treeview li>ul").css('display', 'none'); // Hide all 2-level ul
                $(".collapsible").click(function (e) {
                    $(this).toggleClass("collapse-tree expand-tree");

And it works fine but instead of having it in a separate view I want to integrate it it my main manu. I want to display the result from the view above in the code below where I have the text “Display here”.

            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
Display here!!
                        <li>@Html.ActionLink("Video", "Index", "Video")</li>
                        <li>@Html.ActionLink("Photos", "Index", "Photos")</li>

I have looked into Partial View and Html.RenderAction but don’t know what to use

Source: .net

Leave a Reply