I have a list of client-side classes in TypeScript that I need to send to a web method. Here is my TypeScript code:
class MakeReportData {
LocalName: string;
FldSi: number;
ViewSi:number;
TypeName:string ;
CheckBoxshow :boolean ;
CheckBoxFilter:boolean;
}
Below is my Ajax code:
var temp: MakeReportData[] = [];
for (var i = 0; i < $scope.myData.ReportDetail.length; i++) {
var rep: MakeReportData=new MakeReportData();
rep.LocalName = $scope.myData.ReportDetail[i].LocalName;
rep.FldSi = $scope.myData.ReportDetail[i].FldSi;
rep.ViewSi = $scope.myData.ReportDetail[i].ViewSi;
rep.TypeName = $scope.myData.ReportDetail[i].TypeName;
rep.CheckBoxshow = $scope.myData.ReportDetail[i].CheckBoxshow;
rep.CheckBoxFilter = $scope.myData.ReportDetail[i].CheckBoxFilter;
temp.push(rep);
}
var tedata = JSON.stringify({ itm: temp });
alert(tedata);
$.ajax({
type: "POST",
url: "MakeReport.aspx/GetList",
contentType: "application/json; charset=utf-8",
data: tedata ,
dataType: "json",
success: function (data) {
alert(data.d);
},
error: function (data, status, jqXHR) {
alert(status);
alert(jqXHR);
}
});
Here is my web method:
[WebMethod]
public static string GetList(MakeReportData[] itm)
{
return "";
}
And here is the C# class I am using:
public class MakeReportData
{
public string LocalName { get; set; }
public int FldSi { get; set; }
public int ViewSi { get; set; }
public string TypeName { get; set; }
public bool CheckBoxshow { get; set; }
public bool CheckBoxFilter { get; set; }
}
My issue is that the web method is not being called when I try to send the list of MakeReportData objects.