我的Pagemethod实施在Chrome浏览器中无效。我在VS 2008中开发了ASP.NET 3.5 Web应用程序。
以下代码不适用于chrome或Safari:
function FetchDataOnTabChange(ucName)
{
PageMethods.FetchData(ucName, OnSuccessFetchDataOnTabChange, OnErrorFetchDataOnTabChange);
}
function OnErrorFetchDataOnTabChange(error)
{
//Do something
}
function OnSuccessFetchDataOnTabChange(result)
{
//Do something
}
这应该适用于所有浏览器,请按照以下步骤操作:
这来自一个有效的应用程序
aspx页面:
/* the script manager could also be in a master page with no issues */
<asp:ScriptManager ID="smMain" runat="server" EnablePageMethods="true" />
<script type="text/javascript">
function GetDetails(Id) {
PageMethods.GetDetails(doorId);
}
</script>
代码背后:
[System.Web.Services.WebMethod]
public static void GetDetails(string Id)
{
}