0
我有一個簡單的WebMethod,這基本上是過濾的報告在我的代碼隱藏: -通過泛型列表從jQuery來的C#代碼隱藏
[WebMethod(EnableSession = true)]
public static List<Report> FetchReports(string reportName)
{
List<Report> FetchedReports = dataModel.PopulateLinks().Where(r => r.Name.ToLower().Contains(reportName.ToLower())).ToList();
return FetchedReports;
}
現在這個返回到這個jQuery功能: -
$("#reports-textSearch").keyup(function() {
var textLength = $(this).val().length;
if (textLength > 2) {
var args = {
reportName: document.getElementById('reports-textSearch').value
};
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Dashboard.aspx/FetchReports",
data: JSON.stringify(args),
dataType: "json",
success: function(r) {
var reports = r.data;
$.each(reports, function (index, report) {
$("#div1").append("<strong>" + report.Name + "</strong>" + "<br/>" +
"ID: " + report.Id + "<br />" +
"DisplayName: " + report.DisplayName + "<br />" +
"Url: " + report.Url + "<br />" +
"ParentId: " + report.ParentId + "<br />" +
"ReportGroupId: " + report.ReportGroupId + "<br />" +
"AccessLevel: " + report.AccessLevel + "<br />");
alert(reports);
});
//var reports = data.d;
//__doPostBack('div#UPMainMenu', reports());
},
error: function (data) {
alert("Error");
}
});
}
});
我希望將其提交回另一個頁面,從那裏我將得到搜索結果並填充另一個面板。
此刻此代碼不起作用,我該如何更改代碼的$ .each部分,以返回實際的List,以及如何在C#代碼隱藏中操作該代碼以獲得期望的過濾報告?
感謝您的幫助和時間