Search code examples
sharepoint-2010web-partsautocompleteextender

AutoCompleteExtender not working in Sharepoint 2010


This has been bothering me for a few days now. I'm trying to use the AutoCompleteExtender in a Visual Web Part project for Sharepoint 2010 but when I type in characters nothing happens. At first I thought it was an Ajax issue so I used the TextBoxWatermarkExtender and that works, so it must not be an ajax thing.

I followed this guys guide VERBATIM: http://ranaictiu-technicalblog.blogspot.com/2010/08/ajax-control-toolkit-with-sharepoint.html

Here's my ascx:

<%@ Register Assembly="AjaxControlToolkit, Version=3.0.30930.28736, Culture=neutral,         PublicKeyToken=28f01b0e84b6d53e"
Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server"
 TargetControlID="TextBox1"
  WatermarkText="I'm awesome">
</cc1:TextBoxWatermarkExtender>

<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
TargetControlID="TextBox1" ServiceMethod="GetCompletionList">
</cc1:AutoCompleteExtender>

Here's my codebehind:

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace TestingAjax2.TestingAjax2
{

    public partial class TestingAjax2UserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        [System.Web.Services.WebMethod]
        [System.Web.Script.Services.ScriptMethod]
        public string[] GetCompletionList(string prefixText, int count)
        {
            string[] n = { "banana", "orange", "apple", "tunafish" };
            return n;
        }

    }
}

Any help would be appreciated. I'm working with one other guy and we're both completely baffled as to why it isn't working.


Solution

  • You cannot host Scriptservice methods directly in user controls, just pages.