예제 #1
0
        private static IHtmlContent CreateLookupValues <TModel, TProperty>(IHtmlHelper <TModel> html, MvcLookup lookup, Expression <Func <TModel, TProperty> > expression)
        {
            Object value = LookupExpressionMetadata.GetValue(html, expression).Model;
            String name  = LookupExpressionMetadata.GetName(expression);

            if (lookup.Multi)
            {
                return(CreateLookupValues(html, lookup, name, value));
            }

            IDictionary <String, Object> attributes = new Dictionary <String, Object>
            {
                ["class"]        = "mvc-lookup-value",
                ["autocomplete"] = "off"
            };

            TagBuilder container = new TagBuilder("div");

            container.AddCssClass("mvc-lookup-values");
            container.Attributes["data-for"] = name;

            container.InnerHtml.AppendHtml(html.HiddenFor(expression, attributes));

            return(container);
        }
예제 #2
0
        public static TagBuilder LookupFor <TModel, TProperty>(this IHtmlHelper <TModel> html,
                                                               Expression <Func <TModel, TProperty> > expression, MvcLookup model, Object?htmlAttributes = null)
        {
            String     name   = LookupExpressionMetadata.GetName(expression);
            TagBuilder lookup = CreateLookup(model, name, htmlAttributes);

            lookup.InnerHtml.AppendHtml(CreateLookupValues(html, model, expression));
            lookup.InnerHtml.AppendHtml(CreateLookupControl(html, model, name));
            lookup.InnerHtml.AppendHtml(CreateLookupBrowser(name));

            return(lookup);
        }
예제 #3
0
        public static TagBuilder AutoCompleteFor <TModel, TProperty>(this IHtmlHelper <TModel> html,
                                                                     Expression <Func <TModel, TProperty> > expression, ALookup model, Object?htmlAttributes = null)
        {
            String     name   = LookupExpressionMetadata.GetName(expression);
            TagBuilder lookup = CreateLookup(model, name, htmlAttributes);

            lookup.AddCssClass("mvc-lookup-browseless");

            lookup.InnerHtml.AppendHtml(CreateLookupValues(html, model, expression));
            lookup.InnerHtml.AppendHtml(CreateLookupControl(html, model, name));

            return(lookup);
        }