• 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()));
            }
  • 相关阅读:
    idea actiBPM插件之中文乱码
    quartz 集成到Spring中
    Spring 中将service 注入到普通的工具类中
    idea 将java 项目 打包成jar包
    异常来自 HRESULT:0x80070057 (E_INVALIDARG))
    Entity Framework小知识
    C# Unix时间戳转换
    Asp.NET MVC+WebAPI跨域调用
    位运算逻辑与逻辑或逻辑非运算 c# 中如何使用
    c# 学习笔记 重载、重写、重构、构造函数、new、Class
  • 原文地址:https://www.cnblogs.com/jasonlny/p/4250418.html
Copyright © 2020-2023  润新知