I would like to provide my Action with an array of integer values (based on selected checkbox values on a form). I am trying to use Ajax.ActionLink as follows…
<%= Ajax.ActionLink("Submit", "PrintPinLetters", "EPOC", new { selectedItemsToPrint }, new AjaxOptions { HttpMethod="POST", UpdateTargetId = "PrintConfirmation", LoadingElementId = "resultLoadingDiv", OnFailure="handleError"}, new { id = "btnPrintPinLetter" }) %>
but am not sure what to pass into the routeValue section. My Action in the controller is defined as…
[HttpPost]
public ActionResult PrintPinLetters(Int64[] selectedItemsToPrint)
{
Basically I am looking to pass an array (or comma separated list of ID values) in the ‘selectedItemsToPrint’. This list would be build using the values defined by checkboxes (all named the same) in multiple rows of a table.
I have used Ajax.BeginForm but as this results in a nested form I was having unpredictable results when using older browsers (IE 7 and 8).
normally i would do the ajax myself with a jQuery call. You would set it up like this
create an onready function
dont forget to set the name attribute of all of the input elements to selectedItemsToPrint so the binding will work correctly with your actionresult
The Html should look something like this