william

william

  • NA
  • 8
  • 3.7k

Posting listboxdetails back to ActionResult via @Html.ActionLink

Dec 7 2011 4:27 AM
Hi All,

On an MVC3 project I have a form with the classic 2 listbox setup and Moving items between them.
I had all this working fine on a submit button and a bit of JQuery picking up the values before posting them via an Ajax/Json call to the server. I have now been told that I am not allowed to do it this way and instead I have to use an @Html.ActionLink with a post to an ActionResult. Does anybody have a good example of how to get this working. I've looked and tried loads of things, but I just cannot get the items in the listboxes to post back.

Here is 1 of the listboxes (the other is basically the same).

@Html.ListBox("Available", new MultiSelectList(Model.AvailableFloatingZones, "PolicyID", "FullAddress", new { style = "width:100%" })

My Controller Method signature:

public ActionResult Link(int policyZoneID, string[] available).... I have also tried List<string> available

My button:

@Html.ActionLink("Link/Unlink", "Link", "PolicyZone", new { policyZoneID = Model.PolicyZoneID, available =  }, new { @class = "btnProcess" })

how do I capture the listbox contents to pass in the above statement. Also as an aside, I notice that there is also an @ajax.ActionLink can anybody tell me the difference between the 2.