直接上代码:
一,创建菜单
Action
public ActionResult GetMenu()
{
//获取菜单
List<MenuItem> mainMenu = mm.GetMenuByUser(CurrentUser);
return PartialView("~/Views/MainPage/GetMenu.cshtml", mainMenu);
}
View
@model List<BLL.Models.Entitys.MenuItem>
<ul >
@foreach (var item in Model)
{
//target指向 iframe name
<li><a href="item.菜单路径" target="myFrameName">@item.菜单名称</a></li>
}
</ul>
二,创建主页面,引用菜单action
<div class="main" id="menu">
@Html.Action("GetMenu")
<iframe id="myFrameName" name="myFrameName" frameborder="0" scrolling="auto" width="100%" ></iframe>
</div>