1
I’m having some difficulty in assembling a Helper to assemble the system menu
This is my view
@model IList<Devcompy.ClientWeb.Devcompy2.Helpers.HierarchyNode<Devcompy.Models.Entities.Segurancas.Menu>>
<!-- Navigation -->
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Devcompy", "Index", "Home", null, new { @class = "navbar-brand" })
</div>
<ul class="nav navbar-top-links navbar-right">
<li>
<a href="javascript:document.getElementById('logoutForm').submit()"><i class="fa fa-sign-out fa-fw"></i> Sair</a>
</li>
</ul>
<!-- /.navbar-top-links -->
<div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">
@foreach (var model in Model)
{
<li>
@{var firstMenu = model.Entity;}
<a class="active" href="@Url.Action(firstMenu.Action, firstMenu.Controller, new { @area = firstMenu.Area })"><i class="fa fa-dashboard fa-fw"></i> @firstMenu.Title</a>
</li>
if (model.Entity.Menus.Count > 0)
{
DropDownMenu(model.Entity.Menus.ToList());
}
}
</ul>
</div>
</div>
<!-- /.navbar-static-side -->
</nav>
<!-- /.Navigation -->
@if (Request.IsAuthenticated)
{
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
{
@Html.AntiForgeryToken()
}
}
@helper DropDownMenu(List<Devcompy.Models.Entities.Segurancas.Menu> menus)
{
foreach (var menu in menus)
{
<li>
<a href="#">@menu.Title<span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li>
<a href="flot.html">Clientes</a>
</li>
<li>
<a href="morris.html">Produtos</a>
</li>
</ul>
<!-- /.nav-second-level -->
</li>
}
}
The difficulty is in the following question, when calling the Helper DropDownMenu
passing the list he is not entering is not arriving at the foreach
from my Helper, I know that my list has items.
Not even editing my Helper to not receive parameter it is working
If you debug what comes at breakpoint ?
– Érik Thiago
The menu parameter appears with 1 item, but does not arrive in foreach
– Pablo Tondolo de Vargas