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()));
            }
  • 相关阅读:
    QT5.4 vs2013静态加载插件的sqlite静态编译
    四个漂亮的CSS样式表
    程序猿写的程序将如何打包成安装包(最简单)
    cocos2d的-X- luaproject的LUA脚本加密
    【【分享】深入浅出WPF全系列教程及源码 】
    C#的StringBuilder 以及string字符串拼接的效率对照
    【Android中Broadcast Receiver组件具体解释 】
    【蜗牛—漫漫IT路之大学篇(九) 】
    【分布式存储系统sheepdog 】
    C#异步调用
  • 原文地址:https://www.cnblogs.com/jasonlny/p/4250418.html
Copyright © 2011-2022 走看看