zoukankan      html  css  js  c++  java
  • MVC5 方法扩展

    public static MvcHtmlString DataDictionaryDropDownList(this HtmlHelper htmlHelper, string name, object htmlAttributes, List<SelectListItem> selectListItem)
            {
                return SelectExtensions.DropDownList(htmlHelper, name, selectListItem, htmlAttributes);
            }
    
            public static MvcHtmlString DataDictionaryDropDownList(this HtmlHelper htmlHelper, string name, string dataKeyName, object htmlAttributes, string checkedValue = null, IDataDictionaryAdapter adapter = null, params SelectListItem[] moreSelectItem)
            {
                //默认适配器
                if (adapter == null) adapter = new DataDictionaryAdapter();
    
                List<SelectListItem> selectListItem = adapter.GetSelectListItem(dataKeyName, checkedValue);
    
                //添加更多选择
                if (moreSelectItem != null) selectListItem.InsertRange(0, moreSelectItem);
    
                return DataDictionaryDropDownList(htmlHelper, name, htmlAttributes, selectListItem);
            }
            public static MvcHtmlString DataDictionaryDropDownList<T>(this HtmlHelper htmlHelper, string name, string dataKeyName, object htmlAttributes, string checkedValue = null, IDataDictionaryAdapter adapter = null, Action<T> beforeAction = null, params SelectListItem[] moreSelectItem)
            {
                //默认适配器
                if (adapter == null) adapter = new DataDictionaryAdapter();
    
                List<SelectListItem> selectListItem = adapter.GetSelectListItem<T>(dataKeyName, checkedValue, beforeAction);
    
                //添加更多选择
                if (moreSelectItem != null) selectListItem.InsertRange(0, moreSelectItem);
    
                return DataDictionaryDropDownList(htmlHelper, name, htmlAttributes, selectListItem);
            }
    
            public static MvcHtmlString ActionLink2(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes)
            {
                MvcHtmlString result = LinkExtensions.ActionLink(htmlHelper, linkText, actionName, routeValues, htmlAttributes);
                return HtmlDecode(result);
            }
            public static MvcHtmlString ActionLink2(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object htmlAttributes)
            {
                MvcHtmlString result = LinkExtensions.ActionLink(htmlHelper, linkText, actionName, controllerName, null, htmlAttributes);
                return HtmlDecode(result);
            }
            public static MvcHtmlString ActionLink2(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes)
            {
                MvcHtmlString result = LinkExtensions.ActionLink(htmlHelper, linkText, actionName, controllerName, routeValues, htmlAttributes);
                return HtmlDecode(result);
            }
    
            private static MvcHtmlString HtmlDecode(MvcHtmlString mvcHtmlString)
            {
                return new MvcHtmlString(HttpUtility.HtmlDecode(mvcHtmlString.ToHtmlString()));
            }
  • 相关阅读:
    docker 安装nginx 并部署 配置本地化
    vue安装tinyMCE
    gitignore文件不生效的问题解决
    docker安装Mysql挂载数据卷 实现容器配置本地化
    淘宝网店经营场所证明如何下载
    leetcode 100.相同的树
    深度优先搜索和广度优先搜索
    leetcode 329 矩阵中的最长递增路径
    leetcode 410 分割数组的最大值
    leetcode 95 不同的二叉搜索树II
  • 原文地址:https://www.cnblogs.com/jasonlny/p/4250418.html
Copyright © 2011-2022 走看看