public static MvcHtmlString TextBoxBindFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, object htmlAttributes) { var bind = new KnockoutBind(null, htmlAttributes); bind.AddBind("value", ExpressionHelper.GetExpressionText(expression)); return(InputExtensions.TextBoxFor(htmlHelper, expression, bind)); }
public static MvcHtmlString TextBoxFor <TModel, TValue>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TValue> > expression, string title = null, string placeholder = null, bool autofocus = false, bool required = false, Html5InputTypes type = Html5InputTypes.Text, string icon = null, object htmlAttributes = null ) { RouteValueDictionary rvd = new RouteValueDictionary( HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)); rvd.Add("type", type.ToString()); rvd.Add("class", "form-control"); rvd.Add("stype", "text-align: center;"); if (required) { rvd.Add("required", ""); } if (!string.IsNullOrWhiteSpace(title)) { rvd.Add("title", title); } if (!string.IsNullOrWhiteSpace(placeholder)) { rvd.Add("placeholder", placeholder); } if (autofocus) { rvd.Add("autofocus", ""); } if (!string.IsNullOrEmpty(icon)) { } return(InputExtensions.TextBoxFor(htmlHelper, expression, rvd)); }