zoukankan      html  css  js  c++  java
  • layUI+mvc动态菜单控制器

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Text;
    using LayUIMvcTest.Models;
    namespace LayUIMvcTest.Controllers
    {
    public class MainController : Controller
    {
    //
    // GET: /main/

    public ActionResult Index()
    {
    return View();
    }

    #region 加载菜单数据
    /// <summary>
    /// 加载菜单数据
    /// </summary>
    /// <returns></returns>
    public string LoadMenu()
    {
    StringBuilder str = new StringBuilder();
    wgh_schoolEntities db = new wgh_schoolEntities();
    var menulist = db.sys_menu.SqlQuery("select top 100 * from sys_menu where sys_pid=0 and sys_state=0").ToList();
    if (menulist != null)
    {
    foreach (var item in menulist)
    {
    var pid = item.id;
    str.Append("<li>");
    str.Append("<a href="javascript:;">");
    str.Append("<i class="iconfont">&#xe6b8;</i> <cite>" + item.sys_menuname + "</cite> <i class="iconfont nav_right">&#xe697;</i>");
    str.Append("</a>");
    var childmenulist = db.sys_menu.SqlQuery("select top 100 * from sys_menu where sys_pid=" + pid + " and sys_state=0").ToList();
    if (childmenulist != null)
    {
    str.Append("<ul class="sub-menu">");
    foreach (var submenu in childmenulist)
    {
    str.Append("<li>");
    str.Append("<a _href="/" + (submenu.sys_menuurl) + "">");
    str.Append("<i class="iconfont">&#xe6a7;</i> <cite>" + submenu.sys_menuname + "</cite>");
    str.Append("</a>");
    str.Append("</li>");
    }
    str.Append("</ul>");
    }
    str.Append("</li>");


    }
    }
    return str.ToString();

    }
    #endregion
    }
    }

  • 相关阅读:
    C语言截取从某位置开始指定长度子字符串方法
    vim:放弃hjkl
    vim资源
    PHP和.NET通用的加密解密函数类,均使用3DES加解密 .
    Java与.NET DES加密解密互转
    案例:使用正则表达式的爬虫
    爬虫的正则表达式re模块
    爬虫中Requests模块
    Oracle系列十一 数据处理
    爬虫urllib2 的异常错误处理URLError和HTTPError
  • 原文地址:https://www.cnblogs.com/wugh8726254/p/13027751.html
Copyright © 2011-2022 走看看