PageMethods不工作,因为方法不是从javascript调用的

本文关键字:javascript 调用 方法 工作 因为 PageMethods | 更新日期: 2023-09-27 18:28:03

我有一个页面方法,

 PageMethods.AuthUser(username,password,onsuccess, on fail);

我的代码后台正在跟踪

public string AuthUser(string username,string password){return ""}

我不知道我做错了什么,只是不工作

PageMethods不工作,因为方法不是从javascript调用的

是的,我明白了,我的代码隐藏方法中缺少static,我发现该方法应该与webmethod一起使用。感谢xyz的评论

应该是

[WebMethod]
public static AuthUser(...)

添加ScriptManager属性EnablePageMethods="true"

更改代码

[System.Web.Services.WebMethod]
public static string AuthUser(string username,string password){return ""}