Esempio n. 1
0
        public static MvcHtmlString BallyCheckBoxList <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, ItemDataSource dataSource, int listLength = -1, string[] disabled = null, StylePropertyBag style = null, short tabIndex = 0, string onClickFunction = "", bool isVerticalAllign = false, string cssClass = "")
        {
            string propertyName         = string.Empty;
            string modelName            = string.Empty;
            object value                = string.Empty;
            string errMsg               = string.Empty;
            string chkBoxListHTMLString = string.Empty;
            Dictionary <string, string> overrideSettings;
            string configKey = string.Empty;
            CheckBoxListHTMLEmitter checkBoxListHTMLEmitter;

            ControlExtension.GetPropertyNameAndValue <TModel, TProperty>(htmlHelper, expression, out propertyName, out modelName, out value, out errMsg, out configKey);

            overrideSettings = GetCheckBoxListOverrideSettings(listLength, style, tabIndex, onClickFunction, isVerticalAllign, value, cssClass);
            FillerParams fillerParams = null;

            if (dataSource != null)
            {
                fillerParams = new FillerParams(modelName, propertyName, overrideSettings, list: dataSource.DataSource, valueMember: dataSource.ValueMember, displayMember: dataSource.DisplayMember, configKey: configKey);
            }
            else
            {
                fillerParams = new FillerParams(modelName, propertyName, overrideSettings, list: null, valueMember: string.Empty, displayMember: string.Empty, configKey: configKey);
            }
            var fillers            = ControlPropertyFillerFactory.Get();
            var chkListpropertyBag = new CheckBoxListPropertyBag(fillerParams);

            chkListpropertyBag.Accept(fillers);
            chkListpropertyBag.ErrorMessage = errMsg;
            chkListpropertyBag.IsDirty      = string.IsNullOrEmpty(errMsg) ? false : true;
            checkBoxListHTMLEmitter         = new CheckBoxListHTMLEmitter(value != null ? value.ToString() : string.Empty, chkListpropertyBag);

            checkBoxListHTMLEmitter.Emit(out chkBoxListHTMLString);
            return(MvcHtmlString.Create(chkBoxListHTMLString));
        }