0

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.

dserver
  • 39
  • 1
  • 8
  • did you add the SafeControl entry in the web.config? do you get any error message at all (check SP log, windows event log, iis log etc.)? – int32 Jul 28 '11 at 16:05
  • The safe controls are there and I see one failure in the sharepoint log. It says:07/28/2011 12:32:00.67 w3wp.exe (0x1008) 0x2308 SharePoint Foundation General 8kh7 High Cannot complete this action. Please try again. c6478033-527f-4617-99e0-cf30b384d916. Not very helpful if that is it. I don't know if that's what throwing it though, the log adds about 25 new rows every time I type something into the textfield that is bound to the autocomplete extender. – dserver Jul 28 '11 at 16:34
  • ok, yea well as you've said, the error doesn't really tell us much... from what i know, you have to reference the AjaxControlKit dll in the SharePoint MasterPage aswell (you should be able to find some examples with google) - but i'm not quite sure as i've never used Ajax in one of my solutions... maybe someone else can give you more hints – int32 Jul 28 '11 at 19:28

1 Answers1

1

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

Tibor
  • 26
  • 1