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)); } }