AJAX Control Toolkit 的 AutoCompletionExtender 方法必须是静态的吗?
我有一个网页在某些 TextBox 上使用 AjaxControlToolkit:AutoCompleteExtener 。 该扩展程序需要服务方法,从中获取要显示的数据:
[System.Web.Services.WebMethodAttribute()、System.Web.Script.Services.ScriptMethodAttribute()] 公共静态字符串[] GetCompletionList2(字符串prefixText,int计数,字符串contextKey) { 返回DatabaseSearch.GetUnits().GetSymbolCompletion(prefixText,organizationToSearch); }
在这个方法中,我使用了一些参数=organizationToSearch。但我不希望这个论点是静态的!由于该方法是静态的,我不知道该怎么做。如果我从方法定义中删除“static”关键字,它将不起作用......而且我真的不想将organizationToSearch更改为static!
请帮忙。
I have web page which is using AjaxControlToolkit:AutoCompleteExtener on some TextBox.
This extender requires service method, from which it will get data to display:
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string[] GetCompletionList2(string prefixText, int count, string contextKey)
{
return DatabaseSearch.GetUnits().GetSymbolCompletion(prefixText, organizationToSearch);
}
In this method I use some argument = organizationToSearch. But I don't want this argument to be static ! And since the method is static I don't know what to do. If I remove the 'static' keyword from method definition it won't work... And I really don't want change organizationToSearch to static either!
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它必须是静态的,因为您没有执行页面。当您调用 AjaxMethod 时,您的页面(网络表单)不存在。
It must be static 'cause you're not in the execution of your page. When you're calling an AjaxMethod, your page (webforms) doesn't exists.
正如已经提到的,您处于一个完全新的请求中,不再执行页面(您的页面已经在此阶段呈现)。
您将需要传输参数并将它们传回静态方法。
As already mentioned, you are in a completly new request and not in the execution of your page anymore (your page has already rendered by this stage)..
You will need to transfer and parameters out and pass them back into the static method..