没有 @Html.Button ! [英] There's no @Html.Button !

查看:16
本文介绍了没有 @Html.Button !的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这很奇怪.我看到@Html.Button() 的引用,但是当我输入 Intellisense 没有找到这样的帮助程序时...有下拉列表、隐藏、编辑器等,但没有按钮!

this is weird. I see references out there for @Html.Button() but when I type that Intellisense doesn't find such a helper... there's dropdownlist, hidden, editors, et cetera, but no button!

这是怎么回事?

推荐答案

public static class HtmlButtonExtension 
{

  public static MvcHtmlString Button(this HtmlHelper helper, 
                                     string innerHtml, 
                                     object htmlAttributes) 
  { 
    return Button(helper, innerHtml,
                  HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)
    ); 
  }

  public static MvcHtmlString Button(this HtmlHelper helper, 
                                     string innerHtml,
                                     IDictionary<string, object> htmlAttributes)
  {
      var builder = new TagBuilder("button");
      builder.InnerHtml = innerHtml;
      builder.MergeAttributes(htmlAttributes);
      return MvcHtmlString.Create(builder.ToString());
  }
}

这篇关于没有 @Html.Button !的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆