创建一个静态class和静态方法
public static class Class1
{
public static MvcHtmlString allenTry(this HtmlHelper helper, string id)
{
var html = "<div>ddd</div>";
return new MvcHtmlString(html.ToString());
}
}
然后在前台View
@Html.allenTry("a")
就可以了
本文介绍如何在ASP.NET MVC中创建静态类和静态方法来简化HTML操作,通过实例展示了如何在前台View中调用静态方法,实现代码复用和提高开发效率。
167

被折叠的 条评论
为什么被折叠?



