Hi, I have the following code to retrieve a list of employee names from a webservice. The webservice works fine when tested alone but using it here, it never gets called as I type in the Textbox. If I try the example at
http://ajax.asp.net/ajaxtoolkit/AutoComplete/AutoComplete.aspx, it states the CompletionListCssClass and ones below it are invalid attributes of the Externder class???
In most cases where the WebService method does not get calls becasue the WebMethod Signature does not match with the AutoComplete Extender signature. The Method signature needs to be:
string[] WSMethodName(string prefixText, int count)
You can have different method name but the parameter names and return type needs to be exact match even in case.
chew5574
Member
11 Points
15 Posts
AutoCompleteExtender not calling webservice?
Jun 19, 2007 08:46 PM|LINK
Hi, I have the following code to retrieve a list of employee names from a webservice. The webservice works fine when tested alone but using it here, it never gets called as I type in the Textbox. If I try the example at http://ajax.asp.net/ajaxtoolkit/AutoComplete/AutoComplete.aspx, it states the CompletionListCssClass and ones below it are invalid attributes of the Externder class???
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender runat="server"ID="autoComplete1"
TargetControlID="TextBox1"
ServiceMethod="RetrieveEmployeesByLastName"
ServicePath=http://localhost:4766/MyApp/WebServices/AjaxWS.asmx
MinimumPrefixLength="2"
CompletionInterval="1000"
EnableCaching="true"
CompletionSetCount="20">
</cc1:AutoCompleteExtender>
KaziManzurRa...
Contributor
4802 Points
887 Posts
Re: AutoCompleteExtender not calling webservice?
Jun 19, 2007 09:18 PM|LINK
In most cases where the WebService method does not get calls becasue the WebMethod Signature does not match with the AutoComplete Extender signature. The Method signature needs to be:
string[] WSMethodName(string prefixText, int count)
You can have different method name but the parameter names and return type needs to be exact match even in case.
Kazi Manzur Rashid
_________________________
Blog: http //kazimanzurrashid.com
Twitter: http://twitter.com/manzurrashid
chew5574
Member
11 Points
15 Posts
Re: AutoCompleteExtender not calling webservice?
Jun 20, 2007 03:46 PM|LINK
Thanks but still no luck...here's my code with a test string array. Can you get it to work?
.aspx...
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender
runat="server"
ID="autoComplete1"
TargetControlID="TextBox1"
ServiceMethod="RetrieveByLastName"
ServicePath="http://localhost:4766/Alerts20/WebServices/AjaxWS.asmx"
MinimumPrefixLength="2"
CompletionInterval="1000"
EnableCaching="true"
CompletionSetCount="20">
</cc1:AutoCompleteExtender>
Webservice...
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] RetrieveByLastName(string prefixText, int count)
{
StringCollection names = new StringCollection();
names.Add("a");
names.Add("ab");
names.Add("abc");
names.Add("b");
names.Add("bb");
String[] namesarray = new String[names.Count];
names.CopyTo(namesarray,0);
return namesarray;
}
chew5574
Member
11 Points
15 Posts
Re: AutoCompleteExtender not calling webservice?
Jun 20, 2007 03:47 PM|LINK
Thanks but still no luck...here's my code with a test string array. Can you get it to work?
.aspx...
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender
runat="server"
ID="autoComplete1"
TargetControlID="TextBox1"
ServiceMethod="RetrieveByLastName"
ServicePath="http://localhost:4766/Alerts20/WebServices/AjaxWS.asmx"
MinimumPrefixLength="2"
CompletionInterval="1000"
EnableCaching="true"
CompletionSetCount="20">
</cc1:AutoCompleteExtender>
Webservice...
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] RetrieveByLastName(string prefixText, int count)
{
StringCollection names = new StringCollection();
names.Add("a");
names.Add("ab");
names.Add("abc");
names.Add("b");
names.Add("bb");
String[] namesarray = new String[names.Count];
names.CopyTo(namesarray,0);
return namesarray;
}
KaziManzurRa...
Contributor
4802 Points
887 Posts
Re: AutoCompleteExtender not calling webservice?
Jun 20, 2007 06:01 PM|LINK
You code looks okay to me except one thing. I could not find the web service reference in the ScriptManager Section like the following:.
<asp:ScriptManager ID="TheScriptManager" runat="server">
<Services>
<asp:ServiceReference Path="~/DataService.asmx" />
</Services>
</asp:ScriptManager>
Does it exist in your real code?
Kazi Manzur Rashid
_________________________
Blog: http //kazimanzurrashid.com
Twitter: http://twitter.com/manzurrashid
chew5574
Member
11 Points
15 Posts
Re: AutoCompleteExtender not calling webservice?
Jun 20, 2007 07:10 PM|LINK
Actually, I referenced the AutoComplete sample code and moved
[System.Web.Script.Services.ScriptService]
Above the class declaration in the webservice code file and it works
yakke22
Member
2 Points
7 Posts
Re: AutoCompleteExtender not calling webservice?
Nov 20, 2009 07:22 AM|LINK
waaw that's just amazing ... I searched about 4 hours for this and this last post of yours made me uncomment
<System.Web.Script.Services.ScriptService()> _
and everything works now ... dear god why in hell is that line commented anyway ........... :/
Thanks a bunch !
dumbre.aksha...
Member
10 Points
5 Posts
Re: AutoCompleteExtender not calling webservice?
Jul 18, 2012 11:56 AM|LINK
Thanks dude... I also wested 3 Hrs, just added line <System.Web.Script.Services.ScriptService()> _ and its started working...