how to pass ListBox values back to controller in ASP.NET MVC 2?
how to pass ListBox values back to controller in ASP.NET MVC 2 without using ViewData . I have a listbox on ASP.NET MVC View . When submitting form I want to pass ListBox values back to controller . How to achieve this usi开发者_开发问答ng Jquery or Javascript?
Its very simple . Use FormCollection in your Parameter list of Action method in your controller and then create a String Array for your ListBox values in your model .
Now Assign formvalue["Your_ListBox_value"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
to your newly created String Array in your Controller .
精彩评论