I'm calling a webservice and passing back a List<> from an Ajax call. Now I need to get that value and pass it to code-behind file with a data type of List<>. Can this be done and if so how can I do it. I've looked here for the solution but I didn't see anything like this. I tried a HiddenField but I get an error that it can't convert from List<> to string.
function GetEnrollmentRecords() {
IsLoading = true;
$.ajax({
type: "POST",
url: "EnrollmentService.asmx/GetEnrollmentRecords",
data: "{qryLastRecord: " + LastRecord + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnGetEnrollmentRecordsSuccess,
failure: function (response) {
IsLoading = false;
},
error: function (response) {
IsLoading = false;
}
});
}
function OnGetEnrollmentRecordsSuccess(response) {
var responseObject = response.d;
LastRecord = responseObject.intLastRecord;
var hdnfldVariable = document.getElementById('ListOfEnrollments');
hdnfldVariable.value = Object.values(responseObject.enrollments);
IsLoading = false;
}