public static MvcHtmlString PasswordBind(this HtmlHelper htmlHelper, string name, object value, IDictionary <string, object> htmlAttributes)
        {
            var bind = new KnockoutBind(null, htmlAttributes);

            bind.AddBind("value", name);
            return(InputExtensions.Password(htmlHelper, name, value, bind));
        }
        public static MvcHtmlString TextBoxBind(this HtmlHelper htmlHelper, string name, object value, object htmlAttributes)
        {
            var bind = new KnockoutBind(null, htmlAttributes);

            bind.AddBind("value", name);
            return(InputExtensions.TextBox(htmlHelper, name, value, bind));
        }
        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));
        }
Beispiel #4
0
        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));
        }