开发者

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 .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜