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 ...
随机推荐
- 通过SSH去连接 github 和bitbucket
github 和 bitbucket 都是项目托管服务器, 1 创建SSH private key and public key 首先需要安装git命令, 并且请检查是否有ssh 命令. 打开 Git ...
- Python02(Linux命令)
Trainning-day01回顾 1.who :查看登录到系统的用户信息 2.pwd :查看当前所在路径 3.ls :查看当前目录的内容 ls -l ls -a ls -la / ls -l -a ...
- 后台List里的数据传到前台表格和下拉列表为什么不显示
传到前台表格和下拉列表我是用<c:forEach做的,百度了很久,仔仔细细对我的代码没有问题,那么到底是为什么不显示呢?! 找了很久啊,最后发现是我没有引入jstl的标签库!居然是因为这个…… ...
- border-radius,box-shadow兼容性解决办法
css3 border-radius不支持IE8/IE7的四种解决方法 标签: cssborder-radius兼容性 时间:2016-07-18 css3 border-radius用于设置HT ...
- ASP.NET MVC页面报错System.InvalidOperationException The view found at '~/Views/Home/Index.cshtml' was not created.
Application Exception System.InvalidOperationException The view found at '~/Views/Home/Index.cshtml' ...
- java类.方法创建.继续调用
1.ctrl +n 创建类(首字母大写) 2.alt +s 选倒数第二个 创建方法(Superclass) 3.alt +s 选倒数第三个 创建带参数的方法(using fileds) 4.创建的vo ...
- Hive元数据找回
如果不小心删除了了hive的元数据文件(/user/hive/warehouse),只要先前core-site.xml文件中设置了fs.trash.interval属性就可以找回.hdfs会为用户创建 ...
- Python IO密集型任务、计算密集型任务,以及多线程、多进程
对于IO密集型任务: 直接执行用时:10.0333秒 多线程执行用时:4.0156秒 多进程执行用时:5.0182秒 说明多线程适合IO密集型任务. 对于计算密集型任务 直接执行用时:10.0273秒 ...
- jmeter 上传附件
1.查看上传接口参数,然后写到jmeter中 2.在file upload中parameterName填写main,MIME Type中填写request中的Content-Type
- python bif
filter(过滤器): 语法: filter(function, iterable) funciton 为判断函数 iterable 为可迭代对象 ...