For example we have a view model with fields:
public List<string> SelectedTestItems { get; set; }
public List<SelectListItem> AllTestItems { get; set; }
and view with:
@Html.ListBoxFor(x=>x.SelectedTestItems, Model.AllTestItems)
And now when i open the view, select 3 items in listbox and submit the form(via jquery $.post and $.serialize ), for some reason in controller I get view model with one item in SelectedTestItems collection, and this item is comma separated values that i selected in listbox (SelectedTestItems[0] = “1,2,3”)
is it possible to map listbox to something like this:
SelectedTestItems[0] = “1”,
SelectedTestItems[1] = “2”,
SelectedTestItems[2] = “3” ?
Thank You !
I had tested here and I received each value separated. Can you show all your code? Maybe we can see what is wrong.