AJAX - AutoCompleteExtender ASP.Net 2.0(页面方法与Web服务 [英] AJAX - AutoCompleteExtender ASP.Net 2.0 (Page Method vs. Web Servi
问题描述
我已将AutoCompleteExtender绑定到文本框,以向用户显示建议
。如果我利用网络服务获取
结果,一切正常。但是,我想将Web服务代码放入页面方法中。我运行调试器只是为了发现从未输入[WebMethod]。
以下是我已经尝试过的一些没有成功的事情。看来
这是一个常见的问题。
-将[WebMethod]属性添加到代码隐藏方法的顶部。
-Added / removed" Static"作为公共方法定义的一部分。
- 删除了ServicePath来自AutoCompleteExtender .aspx页面的属性。
我的文本框和扩展程序控件嵌入到用户控件(.ascx)中,
放在ContentPanel中继承来自MasterPage。我不确定这可能是问题的一部分。当我查看浏览器源代码时,
javascript呈现ServicePath。默认情况下我的aspx
页面,但我的[WebMethod]位于pagename.ascx.cs。另外,我试过了
,其中包括ServicePath = pagename.ascx.cs。但仍然没有运气。
此时,我不知道还有什么可以尝试的。我想要移动到页面方法的主要原因是因为我需要访问Web服务可用的控件,而不是
。此外,我不认为我的需求在这里构成
需要网络服务。
任何帮助都将不胜感激!
谢谢,
Trent
您好,
除了
[WebService]属性外,你还必须指定[ScriptMethod]属性。
Best问候,
Henning Krause
" Trent" < Tr *** @ discuss.microsoft.com写信息
新闻:70 ************************* ********* @ microsof t.com ...
>我已将AutoCompleteExtender绑定到文本框以指示建议
用户。如果我利用网络服务获取
结果,一切正常。但是,我想将Web服务代码放入页面方法。
我
只运行调试器才发现永远不会输入[WebMethod]。 />
以下是我已经尝试过的一些没有成功的事情。它是
出现
这是一个常见问题。
-将[WebMethod]属性添加到代码顶部-behind方法。
-Added / removed" Static"作为公共方法定义的一部分。
- 删除了ServicePath来自AutoCompleteExtender的属性.aspx
页。
我的文本框和扩展程序控件嵌入到用户控件(.ascx)中
放置在继承自MasterPage的ContentPanel中。我不确定
如果
这可能是问题的一部分。当我查看浏览器源代码时,
javascript呈现ServicePath。默认情况下我的aspx
页面,但我的[WebMethod]位于pagename.ascx.cs。另外,我试过了
,其中包括ServicePath = pagename.ascx.cs。但仍然没有运气。
此时,我不知道还有什么可以尝试的。我想要移动到页面方法的主要原因是因为我需要访问Web服务可用的控件,而不是
。此外,我不认为我的需求在这里
构成
需要网络服务。
任何帮助都会非常感谢!
谢谢,
Trent
我在[WebService]之后立即应用[ScriptMethod]并且没有修复
它。还有其他想法吗?谢谢!
" Henning Krause [MVP - 交流]"写道:
您好,
除了
[WebService]属性。
祝你好运,
Henning Krause
"遄" < Tr *** @ discuss.microsoft.com写信息
新闻:70 ************************* ********* @ microsof t.com ...
我已将AutoCompleteExtender绑定到文本框以指示建议
用户。如果我利用网络服务获取
结果,一切正常。但是,我想将Web服务代码放入页面方法。
我
只运行调试器才发现永远不会输入[WebMethod]。 />
以下是我已经尝试过的一些没有成功的事情。它是
出现
这是一个常见问题。
-将[WebMethod]属性添加到代码顶部-behind方法。
-Added / removed" Static"作为公共方法定义的一部分。
- 删除了ServicePath来自AutoCompleteExtender的属性.aspx
页。
我的文本框和扩展程序控件嵌入到用户控件(.ascx)中
放置在继承自MasterPage的ContentPanel中。我不确定
如果
这可能是问题的一部分。当我查看浏览器源代码时,
javascript呈现ServicePath。默认情况下我的aspx
页面,但我的[WebMethod]位于pagename.ascx.cs。另外,我试过了
,其中包括ServicePath = pagename.ascx.cs。但仍然没有运气。
此时,我不知道还有什么可以尝试的。我想要移动到页面方法的主要原因是因为我需要访问Web服务可用的控件,而不是
。此外,我不认为我的需求在这里
构成
需要网络服务。
任何帮助都会非常感谢!
谢谢,
Trent
你好,
我有一个使用这个模式的工作自动完成扩展器:
在Codebehind:
[WebMethod]
[ScriptMethod]
公共静态字符串MyMethod(字符串contextKey)
{在
< ajaxToolkit:AutoCompleteExtender runat =" server"
ID = " tbAutoCompleteExtender" TargetControlID =" tbTextBox"
ServiceMethod =" MyMethod"
MinimumPrefixLength =" 2" CompletionInterval =" 1000"
EnableCaching =" true"
CompletionSetCount =" 12" />
请注意,代码隐藏方法必须在.aspx文件中,即使
自动完成扩展程序位于用户控件中。
您是否安装了最新版本的Ajax工具包?它来自
2月...所以只有几天的时间。
祝你好运,
Henning Krause
" Trent" < Tr *** @ discussion.microsoft.com写信息
新闻:F2 ************************* ********* @ microsof t.com ...
>我在[WebService]之后立即应用[ScriptMethod]并且没有'' t fix
吧。还有其他想法吗?谢谢!
" Henning Krause [MVP - 交流]"写道:
>您好,
除了
之外,您还必须指定[ScriptMethod]属性[WebService]属性。
最好的问候,
Henning Krause
Trent < Tr *** @ discussion.microsoft.com写信息
新闻:70 ***************************** ***** @ microso ft.com ...
>我已将AutoCompleteExtender绑定到文本框以指示
到
用户。如果我利用网络服务获取
结果,一切正常。但是,我想将Web服务代码放入一个页面
方法。
我
运行调试器只发现[ WebMethod]永远不会输入
。
以下是我尝试过的一些没有成功的事情。它是
出现
这是一个常见问题。
-将[WebMethod]属性添加到代码顶部-behind方法。
-Added / removed" Static"作为公共方法定义的一部分。
- 删除了ServicePath来自AutoCompleteExtender的属性
.aspx
页面。
我的文本框和扩展程序控件嵌入到用户控件(.ascx)中)
放在继承自MasterPage的ContentPanel中。我不是
肯定
如果
这可能是问题的一部分。当我查看浏览器源代码时,
javascript呈现ServicePath。默认情况下我会查看我的页面,但我的[WebMethod]位于pagename.ascx.cs。另外,我试过了
,其中包括ServicePath = pagename.ascx.cs。但仍然没有运气。
此时,我不知道还有什么可以尝试的。我想要
移动到页面方法的主要原因是因为我需要访问
不是的控件
可用于Web服务。此外,我不认为我的需求在这里
构成
需要网络服务。
任何帮助都会非常感谢!
谢谢,
Trent
I have tied an AutoCompleteExtender to a textbox to indicate suggestions to
the user. Everything works fine if I utilize a webservice to fetch the
results. However, I want to put the web service code into a page method. I
have run the debugger only to find that the [WebMethod] is never entered.
Here are some of the things I have already tried with no success. It appears
that this is a common problem.
-Added the [WebMethod] attribute to the top of the code-behind method.
-Added/removed "Static" as part of the public method definition.
-Removed the "ServicePath" attribute from the AutoCompleteExtender .aspx page.
My textbox and extender control are embedded into a user control(.ascx) that
is placed within a ContentPanel inherited from a MasterPage. I''m not sure if
this could be part of the problem. As I view the browser source code, the
javascript renders the "ServicePath" to be looking by default at my aspx
page, but my [WebMethod] lives in pagename.ascx.cs. Also, I have tried
including "ServicePath=pagename.ascx.cs" and still no luck.
At this point, I don''t know what else to try. The main reason I''m wanting
to move to a page method is because I need access to controls which aren''t
available to the web service. Also, I don''t think my needs here constitute
the need for a web service.
Any help would be greatly appreciated!
Thanks,
Trent
Hello,
you''ll have to specify the [ScriptMethod] attribute in addition to the
[WebService] attribute.
Best regards,
Henning Krause
"Trent" <Tr***@discussions.microsoft.comwrote in message
news:70**********************************@microsof t.com...>I have tied an AutoCompleteExtender to a textbox to indicate suggestions to
the user. Everything works fine if I utilize a webservice to fetch the
results. However, I want to put the web service code into a page method.
I
have run the debugger only to find that the [WebMethod] is never entered.
Here are some of the things I have already tried with no success. It
appears
that this is a common problem.
-Added the [WebMethod] attribute to the top of the code-behind method.
-Added/removed "Static" as part of the public method definition.
-Removed the "ServicePath" attribute from the AutoCompleteExtender .aspx
page.
My textbox and extender control are embedded into a user control(.ascx)
that
is placed within a ContentPanel inherited from a MasterPage. I''m not sure
if
this could be part of the problem. As I view the browser source code, the
javascript renders the "ServicePath" to be looking by default at my aspx
page, but my [WebMethod] lives in pagename.ascx.cs. Also, I have tried
including "ServicePath=pagename.ascx.cs" and still no luck.
At this point, I don''t know what else to try. The main reason I''m wanting
to move to a page method is because I need access to controls which aren''t
available to the web service. Also, I don''t think my needs here
constitute
the need for a web service.
Any help would be greatly appreciated!
Thanks,
Trent
I applied [ScriptMethod] immediately after [WebService] and that didn''t fix
it. Any other thoughts? Thanks!
"Henning Krause [MVP - Exchange]" wrote:
Hello,
you''ll have to specify the [ScriptMethod] attribute in addition to the
[WebService] attribute.
Best regards,
Henning Krause
"Trent" <Tr***@discussions.microsoft.comwrote in message
news:70**********************************@microsof t.com...I have tied an AutoCompleteExtender to a textbox to indicate suggestions to
the user. Everything works fine if I utilize a webservice to fetch the
results. However, I want to put the web service code into a page method.
I
have run the debugger only to find that the [WebMethod] is never entered.
Here are some of the things I have already tried with no success. It
appears
that this is a common problem.
-Added the [WebMethod] attribute to the top of the code-behind method.
-Added/removed "Static" as part of the public method definition.
-Removed the "ServicePath" attribute from the AutoCompleteExtender .aspx
page.
My textbox and extender control are embedded into a user control(.ascx)
that
is placed within a ContentPanel inherited from a MasterPage. I''m not sure
if
this could be part of the problem. As I view the browser source code, the
javascript renders the "ServicePath" to be looking by default at my aspx
page, but my [WebMethod] lives in pagename.ascx.cs. Also, I have tried
including "ServicePath=pagename.ascx.cs" and still no luck.
At this point, I don''t know what else to try. The main reason I''m wanting
to move to a page method is because I need access to controls which aren''t
available to the web service. Also, I don''t think my needs here
constitute
the need for a web service.
Any help would be greatly appreciated!
Thanks,
Trent
Hello,
I''ve a working autocomplete extender using this schema:
In Codebehind:
[WebMethod]
[ScriptMethod]
public static string MyMethod(string contextKey)
{}
In aspx site:
<ajaxToolkit:AutoCompleteExtender runat="server"
ID="tbAutoCompleteExtender" TargetControlID="tbTextBox"
ServiceMethod="MyMethod"
MinimumPrefixLength="2" CompletionInterval="1000"
EnableCaching="true"
CompletionSetCount="12" />
Note that code-behind method must be in the .aspx file, even if the
autocomplete extender is in a usercontrol.
Do you have the latest version of the Ajax toolkit installed? It''s from
february... so only a few days old.
Best regards,
Henning Krause
"Trent" <Tr***@discussions.microsoft.comwrote in message
news:F2**********************************@microsof t.com...>I applied [ScriptMethod] immediately after [WebService] and that didn''t fix
it. Any other thoughts? Thanks!
"Henning Krause [MVP - Exchange]" wrote:
>Hello,
you''ll have to specify the [ScriptMethod] attribute in addition to the
[WebService] attribute.
Best regards,
Henning Krause
"Trent" <Tr***@discussions.microsoft.comwrote in message
news:70**********************************@microso ft.com...>I have tied an AutoCompleteExtender to a textbox to indicate suggestions
to
the user. Everything works fine if I utilize a webservice to fetch the
results. However, I want to put the web service code into a page
method.
I
have run the debugger only to find that the [WebMethod] is never
entered.
Here are some of the things I have already tried with no success. It
appears
that this is a common problem.
-Added the [WebMethod] attribute to the top of the code-behind method.
-Added/removed "Static" as part of the public method definition.
-Removed the "ServicePath" attribute from the AutoCompleteExtender
.aspx
page.
My textbox and extender control are embedded into a user control(.ascx)
that
is placed within a ContentPanel inherited from a MasterPage. I''m not
sure
if
this could be part of the problem. As I view the browser source code,
the
javascript renders the "ServicePath" to be looking by default at my
aspx
page, but my [WebMethod] lives in pagename.ascx.cs. Also, I have tried
including "ServicePath=pagename.ascx.cs" and still no luck.
At this point, I don''t know what else to try. The main reason I''m
wanting
to move to a page method is because I need access to controls which
aren''t
available to the web service. Also, I don''t think my needs here
constitute
the need for a web service.
Any help would be greatly appreciated!
Thanks,
Trent
这篇关于AJAX - AutoCompleteExtender ASP.Net 2.0(页面方法与Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!