zoukankan      html  css  js  c++  java
  • MVC模板页中显示数据

    新建一个模板页的类,让它继承于Controler类,在构造函数中写上ViewData[“MasterPageData”],返回数据。然后在每个用到模板页的Controlers中都继承这个类即可。

    详见:

    public class MasterPageData : Controller   //模板页的类

        {

            BLL.Menu bll = new BLL.Menu();

            public MasterPageData()

            {

                IList<Menu> menuList= bll.GetMenuList();

                ViewData["MasterPageData"] = menuList;

            }

        }

    public class HomeController : MasterPageData

    //继承模板页,模板页继承Controller类,实现向模板页传递数据

    {   }

    <%foreach (Menu menuList in (IList<Menu>)ViewData["MasterPageData"])

    {    //模板页中显示出来}  %>

  • 相关阅读:
    html5——渐变
    html5——背景
    html5——边框
    html5——私有前缀
    html5——盒子模式
    html5——文本阴影
    html5——颜色
    html5——css选择器
    html5——DOM扩展
    html5——多媒体(一)
  • 原文地址:https://www.cnblogs.com/wuzhsh/p/2303066.html
Copyright © 2011-2022 走看看