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
Mario ScheerenRank #1,371 · 1.2K reputationPosted Apr 3, 2019, 12:06 AM EDT
Mark TaborRank #914 · 2.3K reputationPosted Apr 3, 2019, 12:28 AM EDT
Mark TaborRank #914 · 2.3K reputationPosted Apr 3, 2019, 1:23 AM EDT
Mario Scheeren
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts