Dynamic Menu loading in ASP.Net MVC3 Razor

后端 未结 1 1151
梦如初夏
梦如初夏 2021-02-11 06:03

I want to ask about Dynamic Database Driven Menu Loading in ASP.Net

MVC3 razor .

This is my

1.View Code

2.Model for Menu

3.Model For

1条回答
  •  悲&欢浪女
    2021-02-11 07:00

    Put below div in _Shared.cshtml

      
    

    Make new _MenuLayout.cshtml view for dynamic generated menu

    In your controller , write code to get Data from database table e.g. MenuTable and prepare list and assign values like below

      ViewBag.Menu = list;
    

    and in your _MenuLayout.cshtml partial view place below code,

    @{ var menusList = ViewBag.Menu as IEnumerable; }
    
     @if (menusList != null)
    {
       
    }
    

    0 讨论(0)
提交回复
热议问题