コード例 #1
0
        /// <summary></summary>
        public static MvcHtmlString BsDropDownListFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, IEnumerable <SelectListItem> selectList, string optionLabel, 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, htmlAttributes));
            }

            HelperUtils.AddCssClass(htmlAttributes, "form-control");
            return(htmlHelper.DropDownListFor(expression, selectList, optionLabel, htmlAttributes));
        }
コード例 #2
0
        /// <summary></summary>
        public static MvcHtmlString BsRadioList(this HtmlHelper htmlHelper, string name, 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)
            {
                return(staticControlHelper(htmlHelper, null, name, selectList, "radio", htmlAttributes));
            }

            return(htmlHelper.RadioList(name, selectList, htmlAttributes));
        }
コード例 #3
0
        /// <summary></summary>
        public static MvcHtmlString BsDropDownList(this HtmlHelper htmlHelper, string name, IEnumerable <SelectListItem> selectList, string optionLabel, 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)
            {
                return(staticControlHelper(htmlHelper, null, name, selectList, htmlAttributes));
            }

            HelperUtils.AddCssClass(htmlAttributes, "form-control");
            return(htmlHelper.DropDownList(name, selectList, optionLabel, htmlAttributes));
        }
コード例 #4
0
        /// <summary></summary>
        public static MvcHtmlString BsTextArea(this HtmlHelper htmlHelper, string name, string value, 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)
            {
                return(staticControlHelper(htmlHelper, null, name, htmlAttributes));
            }

            HelperUtils.AddCssClass(htmlAttributes, "form-control");
            return(htmlHelper.TextArea(name, value, rows, columns, htmlAttributes));
        }
コード例 #5
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));
        }