I have a list of class that made in client with typescript, Now i want to send it to webmethod. My typescript code is below :
class MakeReportData {
LocalName: string;
FldSi: number;
ViewSi:number;
TypeName:string ;
CheckBoxshow :boolean ;
CheckBoxFilter:boolean;
}
My Ajax code is below :
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);
}
});
my webmethod is below :
[WebMethod]
public static string GetList(MakeReportData[] itm)
{
return "";
}
my class in C# is like this :
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; }
}
I want to send the list of MakeReportData to the server webmethod. My problem is that the webmethod does not call.