Here is return type I want to return Dictionary<ReportID, ReportDatail>
where structure of classes as:
Class ReportDetail
{
ReportID,
ReportName,
ReportShortName,
List<ReportFields>
}
Class ReportFields
{
SystemName,
DBName,
DataType,
MaxLength,
DefaultValue
}
I don't have any idea about how to return that response as dictionary.
function GetReportsDetails(AccoutType) {
$.ajax({
type: "POST",
url: '<%= ResolveUrl("~/Web/ReportPosition.aspx/GetReportDetail") %>',
contentType: "application/json; charset=utf-8",
datatype: 'json',
data: JSON.stringify({SelectedAccount: AccoutType}),
success: function (data) {
alert(data.d);
},
error: function (xhr, status, error) {
alert('XHR: ' + xhr.responseText + '
Status: ' + status + '
Error: ' + error);
}
});
[WebMethod]
public static string GetReportDetail(string AccoutItem)
{
return "Response from WebMethod..!";
//What type of code I've to write here to return "Dictionary<ReportID, ReportDatail>"
}
In above web method I have simply return string rather than Dictionary as response but still gets error as:
Type u0027System.Stringu0027 is not supported for deserialization of an array.
How to pass data to WebMethod
and process response return as Dictionary from WebMethod
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…