public static MvcHtmlString FormCheckBoxFor <TModel>(this HtmlHelper <TModel> helper, Expression <Func <TModel, bool> > expression, string labelText = null, bool radio = false, bool inline = false, bool disabled = false, object htmlAttributes = null) { TagBuilder div = new TagBuilder("div"); IDictionary <string, object> attrsInput = new RouteValueDictionary(), attrsLabel = InternalHelper.AddClassName(htmlAttributes, "form-check-label"); div.AddCssClass("form-check"); if (disabled) { div.AddCssClass("disabled"); } if (inline) { div.AddCssClass("form-check-inline"); } InternalHelper.AddClassName(attrsInput, "form-check-input"); if (disabled) { attrsInput.Add("disabled", "disabled"); } InternalHelper.AddClassName(attrsLabel, "form-check-label"); div.InnerHtml = helper.CheckBoxFor(expression, attrsInput).ToHtmlString() + helper.LabelFor(expression, labelText, attrsLabel).ToHtmlString(); return(new MvcHtmlString(div.ToString())); }
public static MvcHtmlString FormNumberBoxFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, bool hideZero = true, int decimals = 0, bool @readonly = false, bool disabled = false, BootstrapSize size = BootstrapSize.Auto, double?min = null, double?max = null, object htmlAttributes = null) { var values = InternalHelper.AddClassName(htmlAttributes, FormControl); string format = null; if (hideZero) { format = "{0:#"; if (decimals > 0) { format += "." + new string('#', decimals); } format += "}"; } values["type"] = "number"; if (min != null) { values["min"] = min; } if (max != null) { values["max"] = max; } return(helper.TextBoxFor(expression, format, values.InitializeInputControl(size, @readonly, disabled))); }
public static MvcHtmlString FormDateBoxFor <TModel>(this HtmlHelper <TModel> helper, Expression <Func <TModel, DateTime> > expr, BootstrapSize size = BootstrapSize.Auto, bool @readonly = false, bool disabled = false, object htmlAttributes = null) { var values = InternalHelper.AddClassName(htmlAttributes, FormControl); values["type"] = "date"; return(helper.TextBoxFor(expr, Constants.DateBoxValueFormatString, values.InitializeInputControl(size, @readonly, disabled))); }
public static MvcHtmlString HLabelFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, BootstrapSize breakpoint = BootstrapSize.Mediume, int columns = 3, string labelText = null, object htmlAttributes = null) { var values = InternalHelper.ToValues(htmlAttributes); if (columns >= 0) { InternalHelper.AddClassName(values, BootstrapHelper.GetClassName("col", breakpoint, columns)); } return(helper.LabelFor(expression, labelText, values)); }
public static MvcHtmlString FormTextAreaFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, int rows = 0, BootstrapSize size = BootstrapSize.Auto, bool @readonly = false, bool disabled = false, object htmlAttributes = null) { var values = InternalHelper.AddClassName(htmlAttributes, FormControl); if (rows > 0) { values["rows"] = rows; } return(helper.TextAreaFor(expression, values.InitializeInputControl(size, @readonly, disabled))); }
private static IDictionary <string, object> InitializeInputControl(this IDictionary <string, object> htmlAttributes, BootstrapSize size, bool @readonly, bool disabled) { if (size != BootstrapSize.Auto) { InternalHelper.AddClassName(htmlAttributes, "form-control-" + BootstrapHelper.GetSizeName(size)); } if (@readonly) { htmlAttributes.Add("readonly", "readonly"); } if (disabled) { htmlAttributes.Add("disabled", "disabled"); } return(htmlAttributes); }
public static MvcHtmlString FormPasswordFor <TModel>(this HtmlHelper <TModel> helper, Expression <Func <TModel, string> > expression, BootstrapSize size = BootstrapSize.Auto, object htmlAttributes = null) { var attrs = InternalHelper.AddClassName(htmlAttributes, FormControl); return(helper.PasswordFor(expression, attrs.InitializeInputControl(size, false, false))); }
public static MvcHtmlString FormTextBoxFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, string format = null, BootstrapSize size = BootstrapSize.Auto, bool @readonly = false, bool disabled = false, object htmlAttributes = null) { IDictionary <string, object> attrs = InternalHelper.AddClassName(htmlAttributes, FormControl); return(helper.TextBoxFor(expression, format, attrs.InitializeInputControl(size, @readonly, disabled))); }
public static MvcHtmlString DangerValidationMessageFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, string message = null, object htmlAttributes = null) { return(helper.ValidationMessageFor(expression, message ?? string.Empty, InternalHelper.AddClassName(htmlAttributes, "text-danger"))); }
public static MvcHtmlString FormEnumDropDownListFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, string optionLabel = null, BootstrapSize size = BootstrapSize.Auto, bool @readonly = false, bool disabled = false, object htmlAttributes = null) { return(helper.EnumDropDownListFor(expression, optionLabel, InternalHelper.AddClassName(htmlAttributes, FormControl).InitializeInputControl(size, @readonly, disabled))); }