I am following this below toturial for generting menu from Database
https://yogeshdotnet.com/dynamically-add-menu-submenus-asp-net-mvc-using-entity-framework/
it works fine for separate project but when i make the Partial view and calling it my code is not running below is my code of partial view and controller
_MenuPartial code:
- @model IEnumerable
- @{
- ViewBag.Title = "Index";
- Layout = "~/Views/Shared/_Layout.cshtml";
- }
- @*"~/Content/themes/base/jquery-ui.css" rel="stylesheet" />*@
- "~/Content/bootstrap.css" rel="stylesheet" />
- @**@
Index
- class
- @{
- foreach (var item in Model)
- {
- "/Page/@item.MainMenu">@item.MainMenu
- @if (item.tblSubMenus.Count > 0)
- {
- class
- @foreach (var item2 in item.tblSubMenus)
- {
- "/Category/@item2.Controller/@item2.Id"
>@item2.SubMenu- }
- }
- }
- }
Index
My Home controller :
- public PartialViewResult MenuPartial()
- {
- using (var db = new MenuModel())
- {
- var d = db.tblMainMenus.Include(c => c.tblSubMenus).ToList();
- return PartialView("_MenuPartial",d);
- }
- }
I need urgent response if someone can help me
Mark TaborPosted Apr 3, 2019, 5:23 AM
Mario Scheeren
Mark TaborPosted Apr 3, 2019, 4:28 AM
Mario ScheerenPosted Apr 3, 2019, 4:06 AM