我正在查看一些旧代码,我只能假设它曾经起作用。
MyPage.aspx:
function GetCompanyList(officeId) {
var companyList = document.getElementById('<%= CompanyDropDown.ClientID %>');
if (companyList.length == 0)
PageMethods.GetCompanyList(officeId, OnGetCompanyList);
else
EditCompany();
}
并且:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
后台代码:
[System.Web.Services.WebMethod()]
[System.Web.Script.Services.ScriptMethod()]
public IEnumerable<CompanyMinimum> GetCompanyList(int officeId) {
return (
from c in Repository.Query<Company>()
where !c.IsDeleted && c.TypeEnumIndex == (short)CompanyRelationshipType.Hotel
select new CompanyMinimum() {
id = c.Id,
desc = c.Description
}
).ToList();
}
但在第一段代码中调用PageMethods.GetCompanyList()
时,Chrome会报告:
PageMethods未定义
有人能看出是什么改变导致这个无法工作了吗?
注意:我发现类似的问题,但它们似乎都与此代码不能在主页面或用户控件中工作有关,而这里并非如此。