一、MVC HtmlHelper拓展示例
添加拓展类文件 public static class Html { public static DictionaryTestExtensionHtml = new Dictionary () { { 1,"请选择"}, { 2,"北京市"}, { 3,"上海市"} }; public static MvcHtmlString TestDropDownList(this HtmlHelper html) { string result = string.Empty; StringBuilder sb = new StringBuilder(); sb.AppendLine(" "); result = sb.ToString(); return new MvcHtmlString(result); } }视图引用该命名空间@using Demo.Extensions添加拓展控件@Html.TestTestDropDownList();