MVC HtmlHelper 扩展

定义,

namespace System.Web.Mvc

{

  public static class myTab

  {

    public static MvcHtmlString beginJs(this HtmlHelper helper)

    {

      return new MvcHtmlString("<script>function xxtest(obj){obj.style.display=‘none‘;}</script>");

    }

    public static MvcHtmlString tableXX(this HtmlHelper helper)

    {

      TagBuilder tb = new TagBuilder("input");

      tb.MergeAttribute("type", "button");

      tb.MergeAttribute("value", "click me");

      tb.MergeAttribute("onclick","xxtest(xx1)");

      tb.MergeAttribute("style","background-color:red");

      return new MvcHtmlString(tb.ToString(TagRenderMode.Nomal));

    }

  }

}

调用,

@Html.beingJs()

@Html.tableXX()

 

MVC HtmlHelper 扩展,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。