Exemple #1
0
        public static MvcHtmlString CheckBoxList(this HtmlHelper htmlHelper, string name, string codeCategory, object htmlAttributes = null,
                                                 RepeatDirection repeatDirection = RepeatDirection.Horizontal)
        {
            var codes = CodeManager.GetCodes(codeCategory);

            return(ListControlUtil.GenerateHtml(name, codes, repeatDirection, "checkbox", htmlAttributes, null));
        }
Exemple #2
0
        public static MvcHtmlString CheckBoxListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper,
                                                                        Expression <Func <TModel, TProperty> > expression, string codeCategory, object htmlAttributes = null,
                                                                        RepeatDirection repeatDirection = RepeatDirection.Horizontal)
        {
            var           codes    = CodeManager.GetCodes(codeCategory);
            ModelMetadata metadata = ModelMetadata.FromLambdaExpression <TModel, TProperty>(expression,
                                                                                            htmlHelper.ViewData);
            string name = ExpressionHelper.GetExpressionText(expression);
            string fullHtmlFieldName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name);

            return(ListControlUtil.GenerateHtml(fullHtmlFieldName, codes, repeatDirection, "checkbox", metadata.Model,
                                                HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)));
        }