我正在使用token-input plugin在我的 ASP.NET 项目中。
我有一个如下所示的网络方法,
public partial class User : System.Web.UI.Page
{
[WebMethod]
public static List<IdAndName> GetDescriptions()
{
return DBQueryManager.GetDistinctDescriptions();
}
$('#DescriptionFilterTxtBox').tokenInput("User.aspx/GetDescriptions", {
hintText: "Key in atleast 2 chars. First 20 match is displayed.",
searchDelay: 25,
minChars: 1,
resultsLimit: 10,
tokenValue: name
});
我试图从 GetDescriptions
方法获取数据并将其显示在 DescriptionFilterTxtBox
中,但是它不起作用。基本上,该插件无法访问网络方法。
如何从 tokeninput 插件中调用 ASP.Net Web 方法?如有任何帮助/建议,我们将不胜感激。
最佳答案
您的方法需要q参数:
[WebMethod]
public static List<IdAndName> GetDescriptions(string q)
{
return DBQueryManager.GetDistinctDescriptions();
}
Your script must accept a GET parameter named q which will contain the term to search for. E.g. http://www.example.com/myscript?q=query
您还需要从该方法返回一个 JSON。
关于javascript - token 输入无法访问 ASP.Net Web 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31348497/