public override MvcHtmlString TextBoxWithAddOns(HtmlHelper html, string name, object value, string prependValue, string appendValue, object htmlAttributes = null) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } var builder = new FluentTagBuilder("div") .AddCssClass("input-group"); if (!string.IsNullOrEmpty(prependValue)) { builder = builder .StartTag("div") .AddCssClass("input-group-addon") .SetInnerHtml(prependValue) .EndTag(); } builder = builder.AppendContent(html.TextBox(name, value, htmlAttributes).ToString()); if (!string.IsNullOrEmpty(appendValue)) { builder = builder .StartTag("div") .AddCssClass("input-group-addon") .SetInnerHtml(appendValue) .EndTag(); } return(MvcHtmlString.Create(builder.ToString())); }
public override IHtmlContent TextBoxWithAddOns(IHtmlHelper html, string name, object value, string prependValue, string appendValue, object htmlAttributes = null) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } var builder = new FluentTagBuilder("div") .AddCssClass("input-group"); if (!string.IsNullOrEmpty(prependValue)) { builder = builder .StartTag("div") .AddCssClass("input-group-addon") .SetInnerHtml(prependValue) .EndTag(); } var textBoxHtmlAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); textBoxHtmlAttributes.EnsureCssClass("form-control"); var textBox = html.TextBox(name, value, textBoxHtmlAttributes); builder = builder.AppendContent(textBox.GetString()); if (!string.IsNullOrEmpty(appendValue)) { builder = builder .StartTag("div") .AddCssClass("input-group-addon") .SetInnerHtml(appendValue) .EndTag(); } return(new HtmlString(builder.ToString())); }