首页 > 代码库 > MVC5 方法扩展
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 = http://www.mamicode.com/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 = http://www.mamicode.com/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())); }
MVC5 方法扩展
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。