HtmlHelper 自定义扩展
public static class MyHtmlHelper { public static string MyLable(this HtmlHelper htmlHelper, string str) { return string.Format("<span>{0}</span>", str); } public static MvcHtmlString MyHtmlStringLabel(this HtmlHelper helper, string str,int strLength) //扩展防止被编码化 { if (str.Length> strLength) str= str.Substring(0, strLength) +"..."; return new MvcHtmlString(string.Format("<span>{0}</span>", str)); } }
posted on 2017-07-28 16:44 LarvaAndQing 阅读(146) 评论(0) 编辑 收藏 举报