I am using javascript code to postdata to a controller action coded in C#. I am getting a null value when attempting to pass an array of integers in javascript created as follows:
var answers = [];
answers.push(1);
answers.push(2);
answers.push(3);
I can see from javascript alert that the values are going into array as when I try answers.tostring I am getting the value "1,2,3" as expected, I am then trying the following postdata
var postData = {
'surveyID': surveyID,
'questionID': questionID,
'answers': answers,
'answerText': null,
'comment': comment,
'questionType': questionType
};
This is targetting the following controller action but the array of integers does not seem to be carrying across to the controller action as my List is always null
[HttpPost]
public PartialViewResult GoForward(int surveyID, int questionID, List<int> answers, string answerText, string comment, string questionType)
{}
Any know how I can get the postdata array to translate to a List that is not null?
Arrayclass inC#?