Esempio n. 1
0
        //public static MvcHtmlString VnrTextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> helper,
        //    Expression<Func<TModel, TProperty>> expression, string required)
        //{
        //    var result = new StringBuilder();
        //    if (!string.IsNullOrWhiteSpace(required))
        //    {
        //        result.Append(helper.TextBoxFor(expression, new { @class = "k-textbox", required = required }));
        //    }
        //    return MvcHtmlString.Create(result.ToString());
        //}

        public static MvcHtmlString VnrTextBox(this HtmlHelper helper, TextBoxBuilderInfo builderInfo)
        {
            string classDefault = "k-textbox ";

            if (builderInfo.ClassName != null || builderInfo.ClassName != string.Empty)
            {
                classDefault += builderInfo.ClassName;
            }
            string str = "<input type='text' class='" + classDefault + "' ";

            if (builderInfo.Disabled)
            {
                str += " disabled='" + builderInfo.Disabled + "' ";
                builderInfo.CssStyle = "background-color:#f8f8f8;" + builderInfo.CssStyle;
            }
            if (!string.IsNullOrWhiteSpace(builderInfo.Name))
            {
                str += "name='" + builderInfo.Name + "' id='" + builderInfo.Name + "' ";
            }
            builderInfo.CssStyle = "width:" + builderInfo.Width + "px;" + builderInfo.CssStyle;
            if (!string.IsNullOrWhiteSpace(builderInfo.CssStyle))
            {
                str += "style='" + builderInfo.CssStyle + "'";
            }
            str += "/>";
            return(MvcHtmlString.Create(str.ToString()));
        }
Esempio n. 2
0
        public static MvcHtmlString VnrTextBoxFor <TModel, TProperty>(this HtmlHelper <TModel> helper,
                                                                      Expression <Func <TModel, TProperty> > expression, TextBoxBuilderInfo builderInfo)
        {
            var    strId        = helper.ViewData.TemplateInfo.GetFullHtmlFieldId(ExpressionHelper.GetExpressionText(expression));
            string classDefault = "k-textbox ";

            if (builderInfo.ClassName != null || builderInfo.ClassName != string.Empty)
            {
                classDefault += builderInfo.ClassName;
            }
            if (!string.IsNullOrWhiteSpace(builderInfo.Name))
            {
                strId = builderInfo.Name;
            }
            string str = "<input type='text' name='" + strId + "' id='" + strId + "' class='" + classDefault + "' ";

            if (builderInfo.Disabled)
            {
                str += " disabled='" + builderInfo.Disabled + "' ";
                builderInfo.CssStyle = "background-color:#f8f8f8;" + builderInfo.CssStyle;
            }
            builderInfo.CssStyle = "width:" + builderInfo.Width + "px;" + builderInfo.CssStyle;
            if (!string.IsNullOrWhiteSpace(builderInfo.CssStyle))
            {
                str += "style='" + builderInfo.CssStyle + "'";
            }
            if (!string.IsNullOrWhiteSpace(builderInfo.Value))
            {
                str += "value='" + builderInfo.Value + "'";
            }
            if (builderInfo.Readonly)
            {
                str += "readonly";
            }
            str += "/>";
            return(MvcHtmlString.Create(str.ToString()));
        }