how exactly should the 'myArray' array be passed to the mvc controller? I've tried everything but i can't seem to get anything to work
Controller
[HttpPost]
public ActionResult MyAction(MyModel model, List<string> myArray) {
//code...
}
View
$('#dialog').dialog({
//...
buttons: {
"Cancel": function () {
$(this).dialog("close");
},
"Submit": function () {
var arrCount= 0;
var myArray = new Array();
//grabs all the dropdownlists that begin with id 'dropdownlist' and adds it to 'myArray'
$('form').contents().find("select[id ^= 'dropdownlist'] option:selected").each(function () {
myArray[arrCount++] = $(this).text();
});
if ($('form').validate().form()) {
$.ajax({
url: "MyController/MyAction",
type: 'POST',
dataType: "json",
traditional: true,
data: {
model: $("form").serialize(),
myArray: myArray
},
success: function (result) {
alert("debug: complete");
}
});
}
}
}
});
I know how to pass in the array by itself to the controller. But, once i add my existing model into the equation, i'm unsure as to how i would be able pass my array to the controller. Any thoughts?