ajaxToolkit:AutoCompleteExtender class is not detecting my web service

Posted by Poster under ASP.NET AJAX on 12/3/2008 | Views : 11782 | Status : [Member] | Replies : 3
Hi

I am using AutoComplete ASP.NET AJAX Control toolkit AutoCompleteExtender control (http://forums.asp.net/t/1292855.aspx).
When I am using my web service as Service Path, its not working.

Any clue?




Responses

Posted by: Raja on: 12/3/2008 [Member] Starter

Up
0
Down
Ensure that the attribute of your web service class is following

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class AutoCompleteService : System.Web.Services.WebService
{

}


Notice [System.Web.Script.Services.ScriptService]. Without this even if there is no error in the web service, your extender control will not work.

Also you need to specify the path of the webservice as the path from the root like this.

ServicePath="~/Service/MyAutoCompleteService.asmx" 


Hope this will help you.
Thanks


Regards,
Raja, USA

Poster, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajastudies on: 3/18/2009 [Member] Starter

Up
0
Down
hi add web reference...
steps ... as usual u include webservice then u open solution explorer then add web service ... (choose ur service)add webservice for in this solution its working fine for me any doubts contact mail

Poster, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Anup1252000 on: 8/2/2009 [Member] Starter

Up
0
Down
<body>

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server"
DelimiterCharacters="" Enabled="True" ServiceMethod="GetCompletionList"
ServicePath="" TargetControlID="TextBox1" UseContextKey="True" MinimumPrefixLength="1">
</cc1:AutoCompleteExtender>
</div>
</form>
</body>


within the codebehind(.cs)
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]

public static string[] GetCompletionList(string prefixText, int count, string contextKey)
{
string conn = ConfigurationManager.ConnectionStrings["employeeConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(conn);

DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("SELECT [empname] FROM [employee]", con);
da.Fill(ds,"employee");

string[] main = new string[0];
for (int i = 0; i < ds.Tables[0].Rows.Count-1; i++)
{
if (ds.Tables[0].Rows[i].ItemArray[0].ToString().ToLower().StartsWith(prefixText.ToLower()))
{
Array.Resize(ref main, main.Length + 1);
main[main.Length - 1] = ds.Tables[0].Rows[i].ItemArray[0].ToString ();
if (main.Length == 10)
break;
}

}
Array.Sort(main);
return main;
}


https://wordpress.com/pages/anuphosur.wordpress.com

Poster, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response