AutoCompleteExtender does not work in SharePoint web part

Topics: Developer Forum
Oct 1, 2009 at 9:22 PM


I use AutoCompleteExtender in SharePoint (SP) web part project. Here is the details:

1. I use WSPBuilder ( to build my SP web part. The web part has Ajax feature. That is ScriptManager exists on the sharepoint page. In the CreateChildControls method of the web part, I have these code:

private AutoCompleteExtender autoComplete = new AutoCompleteExtender();

private TextBox TB_SearchSubject = new TextBox();

protected override void CreateChildControls()



                    TB_SearchSubject.ID = "TB_SearchSubject";

                    TB_SearchSubject.Width = 120;


                    System.Web.UI.HtmlControls.HtmlGenericControl div = new System.Web.UI.HtmlControls.HtmlGenericControl();

                    div.ID = "ListPlacement";

                    div.Attributes["style"] = "height:300px; overflow-y:scroll;";



                    autoComplete.ID = "AutoComplete1";

                    autoComplete.MinimumPrefixLength = 1;

                    autoComplete.CompletionSetCount = 20;

                    autoComplete.CompletionInterval = 1000;

                    autoComplete.DelimiterCharacters = ";, :";

                    autoComplete.CompletionListElementID = "ListPlacement";

                    autoComplete.EnableCaching = true;

                    autoComplete.ServicePath = "../12/TEMPLATE/LAYOUTS/AutoCompleteWebService.asmx";

                    autoComplete.ServiceMethod = "GetSubjects";

                    autoComplete.TargetControlID = "TB_SearchSubject";

                    //autoComplete.ContextKey = "SubjectID|CLL";




2. The web service file AutoCompleteWebService.asmx has this code:


[WebService(Namespace = "")]

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]


    public class AutoCompleteWebService : System.Web.Services.WebService





        public string[] GetSubjects(string prefixText, int count, string contextKey)



            if (count == 0)


                count = 10;



            List<string> items = new List<string>(count);


            ArrayList arr_test = new ArrayList();







            for (int i = 0; i < arr_test.Count; i++)


                items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(arr_test[i].ToString(), arr_test[i].ToString()));



            return items.ToArray();





3. Now, I build and deploy WSP file to the SharePoint server in my dev box. Deployment is OK. The web part is also available on the sharepoint page. I have checked the file AutoCompleteWebService.asmx indeeds locates at ../12/ TEMPLATE/LAYOUTS/AutoCompleteWebService.asmx.


Now, I enter “a” to the text box, a list of “undefined” appears (all the items are “undefined”). If everything worked, “ab” should be displayed as I have “ab” item in the ArrayList (see the code above).


4. If I place the AutoCompleteExtender to a normal ASP.NET app and the web service asmx file exactly has the same code as above, it works and “ab” is shown.


So, what things go wrong in the SharePoint web part?


If you know what problem is, could you make comment about it? Thanks.