Hi All,
I have the following code that initially populates 2 listboxes and I do the classic on screen of moving items between the 2 list boxes. This all works fine. To get the data from both listboxes back to my controller, I was using a combination of Jquery with an Ajax/JSON call and this was also working fine.
I have now been told that I cannot use the Ajax/Json combination and instead should use the ActionResult on the controller with an @Html.ActionLink.
The problem I have is that I cannot seem to get the items that are in the listboxes to postback on the action.
Here's the code:
these populate the listboxes. the 2 buttons use a bit of Javascript to move the items between the listboxes this is all ok.Code:<td style="width:46%">@Html.ListBox("Available", new MultiSelectList(Model.AvailableFloatingZones, "PolicyZoneID", "FullAddress"), new { style = "width:100%" })</td> <td style="width:8%"><center><input type="button" name="add" id="add" value=">>" /><br /><br /><input type="button" name="remove" id="remove" value="<<" /></center></td> <td style="width:46%">@Html.ListBox("Assigned", new MultiSelectList(Model.AllocatedFloatingZones, "PolicyZoneID", "FullAddress"), new { style = "width:100%" })</td>
as mentioned I originally had a submit button and then captured the values using:
the same for the other listbox before making an ajax call to the server passing these values. (all was working).Code:var assignedArray = $.map($("#Assigned option"), function (item) { return $(item).attr("value"); });
Now I need to change the submit button to something like :
How do I get my Available list into the available variable? my method signature at the moment on the controller is:Code:@Html.ActionLink("Link/Unlink", "Link", "PolicyZone", new { policyZoneID = Model.PolicyZoneID, available = }, new { @class = "btnProcess" })
Code:public ActionResult Link(int policyZoneID, List<string> available ) {....




Reply With Quote