コード例 #1
0
        public static MvcHtmlString JQM_DatePicker(this HtmlHelper htmlHelper, string name, object value = null, bool isInline = false)
        {
            var config = new InputConfig(name, Enums.InputType.Text)
            {
                IsInline = isInline
            };

            config.Configuration.Add("data-role", "date");
            return(JQM_Input(htmlHelper, config));
        }
コード例 #2
0
        public static MvcHtmlString JQM_Input(this HtmlHelper htmlHelper, InputConfig config)
        {
            TagBuilder tag = null;

            if (config.InputType == Enums.InputType.TextArea)
            {
                tag = new TagBuilder("textarea");
                config.SetAttributes(tag);
                return(new MvcHtmlString(tag.ToString()));
            }
            else
            {
                tag = new TagBuilder("input");
                config.SetAttributes(tag);
                return(new MvcHtmlString(tag.ToString(TagRenderMode.SelfClosing)));
            }
        }
コード例 #3
0
        public static MvcHtmlString JQM_TextBoxFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, InputConfig config = null, IDictionary <string, object> htmlAttributes = null)
        {
            TagBuilder tagResult = new TagBuilder("div");

            tagResult.MergeAttribute("class", "ui-field-contain");
            if (config == null || (config != null && string.IsNullOrEmpty(config.PlaceHolder)))
            {
                tagResult.InnerHtml += LabelExtensions.LabelFor(htmlHelper, expression).ToHtmlString();
            }

            if (htmlAttributes == null)
            {
                htmlAttributes = new Dictionary <string, object>();
            }

            if (config != null)
            {
                foreach (var item in config.GetAttributes())
                {
                    if (htmlAttributes.Count(p => p.Key == item.Key) == 0)
                    {
                        htmlAttributes.Add(item);
                    }
                }
            }
            tagResult.InnerHtml += InputExtensions.TextBoxFor(htmlHelper, expression, htmlAttributes).ToHtmlString();
            tagResult.InnerHtml += ValidationExtensions.ValidationMessageFor(htmlHelper, expression).ToHtmlString();
            return(tagResult.ToHtml());
        }