public static MvcHtmlString DropDownListMultipleChoiceFor <TModel, TValue>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TValue> > expression, IEnumerable <SelectListItem> list, string label = "", object htmlAttributes = null) { var attributes = new Dictionary <string, object>(); if (htmlAttributes != null) { foreach (var property in htmlAttributes.GetType().GetProperties()) { attributes[property.Name] = property.GetValue(htmlAttributes); } } var numMaxEl = HelperExtensions.NumMaxEl; attributes["data-live-search"] = (list.Count() > numMaxEl) ? "true" : "false"; attributes["data-actions-box"] = "true"; attributes["data-size"] = "10"; attributes["multiple"] = "multiple"; attributes["data-select-all-Text"] = "Select All"; attributes["data-deselect-all-Text"] = "Deselect All"; attributes["data-none-selected-Text"] = "Select..."; attributes["class"] = ( attributes.ContainsKey("class") ? attributes["class"] as string : "" ) + " selectpicker"; return(SelectExtensions.ListBoxFor(helper, expression, list, attributes)); }
public static MvcHtmlString ListBoxFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, IEnumerable <SelectListItem> selectList = null, string cssClass = null, string dir = null, bool disabled = false, string id = null, string lang = null, int?size = null, string style = null, int?tabIndex = null, string title = null) { return(SelectExtensions.ListBoxFor( htmlHelper, expression, selectList, SelectAttributes(cssClass, dir, disabled, id, lang, size, style, tabIndex, title) )); }