Agile App Co.

MVC Razor Multi Select2 Days of Week

When you're trying to do something simple and it turns in to 3 hours work! 

 

Here was our solution for simply getting multiple days picked by a select2 listbox in razor MVC

Model

  public string[] SelectedDays { get; set; }

Razor

@Html.ListBoxFor(m => m.SelectedDays, new MultiSelectList(new[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }), new { id = "selectbox-o", @type = "hidden", @class = "form-control select2-multiple", @multiple = "" })