How to get all ListBox items on submit action
问题 How can I get all ListBox values (not just the selected items) upon submit in an asp.net MVC2 project? I'm using Ajax forms like Ajax.BeginForm("ActionName", new...) . I have already tried to select all the items in the OnBegin event of the Ajax options but not all of the ListBox items are being POSTed to the controller. 回答1: This code works for me! <script type="text/javascript"> $(document).ready(function () { $("#myForm").submit(function (e) { $("#myList option").prop("selected", "selected