zoukankan      html  css  js  c++  java
  • MVC HtmlHelper 扩展

    定义,

     1 namespace System.Web.Mvc
     2 
     3 {
     4 
     5   public static class myTab
     6 
     7   {
     8 
     9     public static MvcHtmlString beginJs(this HtmlHelper helper)
    10 
    11     {
    12 
    13       return new MvcHtmlString("<script>function xxtest(obj){obj.style.display='none';}</script>");
    14 
    15     }
    16 
    17     public static MvcHtmlString tableXX(this HtmlHelper helper)
    18 
    19     {
    20 
    21       TagBuilder tb = new TagBuilder("input");
    22 
    23       tb.MergeAttribute("type", "button");
    24 
    25       tb.MergeAttribute("value", "click me");
    26 
    27       tb.MergeAttribute("onclick","xxtest(xx1)");
    28 
    29       tb.MergeAttribute("style","background-color:red");
    30 
    31       return new MvcHtmlString(tb.ToString(TagRenderMode.Nomal));
    32 
    33     }
    34 
    35   }
    36 
    37 }

    调用,

    @Html.beingJs()

    @Html.tableXX()

    作者:zc
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    hdu 2203 亲和串
    hdu 3999 The order of a Tree
    poj 2299 Ultra-QuickSort
    hdu 1908 Double Queue
    hdu 1556 Color the ball
    hdu 4288 Coder
    hdu 5265 pog loves szh II
    hdu 5058 So easy
    T103763 【模板】矩阵乘法
    T103492 【模板】点双连通分量
  • 原文地址:https://www.cnblogs.com/jmzs/p/3652281.html
Copyright © 2011-2022 走看看