Dynamic Menu loading in ASP.Net MVC3 Razor

后端 未结 1 1238
孤街浪徒
孤街浪徒 2021-02-11 06:15

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 06:40

    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)
提交回复
热议问题