grafic.web 0 Newbie Poster

Hi, i created a Menu controller and inside my views folder i create a page Menu.cshtml with the list of my menus and submenus, now, i would love to show this page in my _Layout.cshtml, this is the code :

@model IEnumerable<Menu3.Models.Menu>

<!-- If the Model isn't null -->
@if (Model != null)
{
    <!-- Iterate through the menus -->
    foreach (var menu in Model)
    {
        <li>@Html.ActionLink(menu.MenuName, "Details", "Menu", new { id = menu.MenuId })</li>

          <!-- Iterate for each Submenu that corresponds to this menu -->
        foreach (var submenu in menu.SubMenus)
        {
            <a href="#">
                @submenu.SubMenuName
                @Html.ActionLink("SubMenu", "Details", "SubMenu", new { id = submenu.SubMenuId }) |
            </a>
        }
    }
}

I already try this

@Html.Partial("Menu","Menu")
@Html.Action("Menu","Menu")

but that gave me errors

Is somebody could help, will be great

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.