我有一个简单的web方法,基本上是在我的代码隐藏中过滤报告: -
[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#代码隐藏中操作它以获取所需的过滤报告?
感谢您的帮助和时间