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(, 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(, 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 方法扩展的更多相关文章
- String对象方法扩展
/** *字符串-格式化 */ String.prototype.format = function(){ var args = arguments;//获取函数传递参数数组,以便在replace回调 ...
- .NET:不要使用扩展方法扩展Object对象。
C#的扩展方法算是一种Minin(掺入)机制,掺入方法有其合理的使用场景,这里说说一种不好的使用场景(个人意见):不要使用扩展方法扩展Object对象.扩展Object会对所有类型的示例有侵入,特别是 ...
- javascript方法扩展
String.prototype.startWith = function(str){ return str.indexOf(str) == 0; }; var str = "abc&quo ...
- jQuery扩展$.fn、$.extend jQery命名方法扩展 练习总结
<script> $.fn.hello = function(){ //扩展jQuery实例的自定义方法,基于$.fn的jq方法扩展 this.click(function(){ ...
- 原生js事件委托(事件代理)方法扩展
原生js事件委托(事件代理)方法扩展: 通过Node底层原型扩展委托方法 /** * 事件委托方法 * @param eventName {string}:事件名称,如'click' * @param ...
- jQuery全局进行方法扩展
<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>01 ...
- jQuery对象进行方法扩展
<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>01 ...
- .NET MVC5+ Dapper+扩展+AutoFac自动注入实现
1.首先创建一个MVC项目 定义Model 层 view 层 index.cshtml 控制器层Controllers等文件 2.在线安装或者引用dapper 以及扩展相关包 同时Autofac ...
- js数组方法扩展
/** * Created by Administrator on 2016/9/1. */ //数组去重 Array.prototype.unique = function(){ this.sort ...
随机推荐
- OpenGL 3D旋转的木箱
学习自: https://learnopengl-cn.github.io/01%20Getting%20started/08%20Coordinate%20Systems/#3d 0,首先添加glm ...
- axis调用Web服务报axis unexpected wrapper element{XXXX}XXX错误的解决
使用axis调用WebService时报错:axis unexpected wrapper element{XXXX}YYY .... expected {XXXX}. 经查,XXXX为wsdl文件中 ...
- js中的正则
闭包: 函数在调用的时候会形成私有的作用域,对内部的变量起到保护的作用,这就是闭包: 变量销毁: 1.人为销毁 : var a = 12: a = null: 2.孜然销毁 : 函数在调用完之后, ...
- React native 中使用Fetch请求数据
一.代码 import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View } from ' ...
- RN集成echarts4图表组件react-native-secharts(转载)
一个webview封装的图表组件.基于百度echarts4,相比native-echarts有echarts自带对象支持,例如渐变色等,用法与官网相同用法. echarts version 4.2.0 ...
- linux终端窗口字体缩放快捷键
环境:ubuntu16.04, 打开终端,有时候log输出一行显示不下 ‘ctrl’ + ‘-’字体缩小,一行显示更多的内容 ‘ctrl’ + ‘shift’ + ‘+’字体变大
- Matlab中的rectangle函数
rectangle函数功能:创建二维矩形对象. rectangle('Position',[x,y,w,h])从点(x,y)开始绘制一个宽w高h的矩形,对坐标轴数据单元指定值.注意,按指定的比例显示矩 ...
- android ui更新
UI只能在主线程中更新. Handler 首先在主线程中创建handler,这样handler是附件到主线程UI中. Handler normalHandler = new Handler() { @ ...
- jmeter 写正则表达式
():括起来的部分就是要提取的. .:匹配任何字符串. +:一次或多次. ?:不要太贪婪,在找到第一个匹配项后停止. 需要根据要取的数据取值 jt: eyJhbGciOiJSUzI1NiJ9.ey ...
- 时间Date.js
<span style="line-height: 25.2px;">/** * 日期解析,字符串转日期 * @param dateString 可以为2017-02- ...