コード例 #1
0
        /// <summary></summary>
        public static MvcHtmlString BsTextAreaFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, int rows, int columns, IDictionary <string, object> htmlAttributes)
        {
            if (htmlAttributes == null)
            {
                htmlAttributes = new Dictionary <string, object>();
            }

            bool isEdit = HelperUtils.IsEditable(htmlAttributes);

            HelperUtils.ClearBoolAttribute(htmlAttributes);
            HelperUtils.StandardAttribute(htmlAttributes);

            if (!isEdit)
            {
                ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
                return(staticControlHelper(htmlHelper, metadata, ExpressionHelper.GetExpressionText(expression), htmlAttributes));
            }

            HelperUtils.AddCssClass(htmlAttributes, "form-control");
            return(htmlHelper.TextAreaFor(expression, rows, columns, htmlAttributes));
        }
コード例 #2
0
        /// <summary></summary>
        public static MvcHtmlString BsCheckboxListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, IEnumerable <SelectListItem> selectList, IDictionary <string, object> htmlAttributes)
        {
            if (htmlAttributes == null)
            {
                htmlAttributes = new Dictionary <string, object>();
            }

            bool isEdit = HelperUtils.IsEditable(htmlAttributes);

            HelperUtils.ClearBoolAttribute(htmlAttributes);
            HelperUtils.StandardAttribute(htmlAttributes);

            if (!isEdit)
            {
                if (expression == null)
                {
                    throw new ArgumentNullException("expression");
                }
                ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
                return(staticControlHelper(htmlHelper, metadata, ExpressionHelper.GetExpressionText(expression), selectList, "checkbox", htmlAttributes));
            }

            return(htmlHelper.CheckboxListFor <TModel, TProperty>(expression, selectList, htmlAttributes));
        }