Trouble using AutoCompleteExtender

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff

    #1

    Trouble using AutoCompleteExtender

    hi

    VS2008

    I have trouble getting the AutoCompleteExt ender to work. I've seen the video
    at
    http://www.asp.net:80/learn/ajax-videos/video-122.aspx but don't understand
    what I do wrong. I've even downloaded the source code next to the video and
    cannot see what I do wrong here. When I run the .aspx webpage, I start
    typing in the textbox but isn't called after I've typed in 3 chars. I know
    that method isn't called as I've set a breakpoint in the start of the
    GetCompletionLi st method.

    In my datasource there is a name with the pattern "uuu", so if I start
    typing "uuu" atleast that name shold be displayed...

    *** markup in my .aspx webpage *************** **
    <asp:ScriptMana ger ID="ScriptManag er1" runat="server">
    <Services>
    <asp:ServiceRef erence Path="~/Services/AutoCompleteNam e.asmx" />
    </Services>
    </asp:ScriptManag er>

    Name: <asp:TextBox ID="txtName" runat="server"> </asp:TextBox>
    <ajaxToolkit:Au toCompleteExten der ID="AutoComplet eExtender1"
    runat="server"
    TargetControlID ="txtName"
    ServicePath="~/Services/AutoCompleteNam e.asmx"
    ServiceMethod=" GetCompletionLi st"
    MinimumPrefixLe ngth="3" CompletionSetCo unt="10" >
    </ajaxToolkit:Aut oCompleteExtend er>

    ******* *************** *

    [WebService(Name space = "http://tempuri.org/")]
    [WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX,
    uncomment the following line.
    // [System.Web.Scri pt.Services.Scr iptService]
    public class AutoCompleteNam e : System.Web.Serv ices.WebService {

    public AutoCompleteNam e () {

    //Uncomment the following line if using designed components
    //InitializeCompo nent();
    }

    [WebMethod]
    public string[] GetCompletionLi st(string prefixText, int count)
    {
    List<NamenameCo llection = Name.GetNames(p refixText, count);
    List<stringname s = null;
    foreach (Name name in nameCollection)
    {
    names.Add(name. surename);
    }
    return names.ToArray() ;
    }

    }

    could it be caused by this: ServicePath="~/Services/AutoCompleteNam e.asmx"
    in the video source code it is ServicePath="Au toCompleteName. asmx", but I've
    created a subfolder for my .asmx files just in case my project will have
    more .asmx files. I thought it was a nice way of keeping the project tidy,
    not having everything in the root folder.....

    any suggestions?


  • Joe Fawcett

    #2
    Re: Trouble using AutoCompleteExt ender



    "Jeff" <it_consultant1 @hotmail.com.NO SPAMwrote in message
    news:ec3VS06SJH A.5900@TK2MSFTN GP05.phx.gbl...
    hi
    >
    VS2008
    >
    I have trouble getting the AutoCompleteExt ender to work. I've seen the
    video at
    http://www.asp.net:80/learn/ajax-videos/video-122.aspx but don't
    understand what I do wrong. I've even downloaded the source code next to
    the video and cannot see what I do wrong here. When I run the .aspx
    webpage, I start typing in the textbox but isn't called after I've typed
    in 3 chars. I know that method isn't called as I've set a breakpoint in
    the start of the GetCompletionLi st method.
    >
    In my datasource there is a name with the pattern "uuu", so if I start
    typing "uuu" atleast that name shold be displayed...
    >
    *** markup in my .aspx webpage *************** **
    <asp:ScriptMana ger ID="ScriptManag er1" runat="server">
    <Services>
    <asp:ServiceRef erence Path="~/Services/AutoCompleteNam e.asmx" />
    </Services>
    </asp:ScriptManag er>
    >
    Name: <asp:TextBox ID="txtName" runat="server"> </asp:TextBox>
    <ajaxToolkit:Au toCompleteExten der ID="AutoComplet eExtender1"
    runat="server"
    TargetControlID ="txtName"
    ServicePath="~/Services/AutoCompleteNam e.asmx"
    ServiceMethod=" GetCompletionLi st"
    MinimumPrefixLe ngth="3" CompletionSetCo unt="10" >
    </ajaxToolkit:Aut oCompleteExtend er>
    >
    ******* *************** *
    >
    [WebService(Name space = "http://tempuri.org/")]
    [WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX,
    uncomment the following line.
    // [System.Web.Scri pt.Services.Scr iptService]
    public class AutoCompleteNam e : System.Web.Serv ices.WebService {
    >
    public AutoCompleteNam e () {
    >
    //Uncomment the following line if using designed components
    //InitializeCompo nent();
    }
    >
    [WebMethod]
    public string[] GetCompletionLi st(string prefixText, int count)
    {
    List<NamenameCo llection = Name.GetNames(p refixText, count);
    List<stringname s = null;
    foreach (Name name in nameCollection)
    {
    names.Add(name. surename);
    }
    return names.ToArray() ;
    }
    >
    }
    >
    could it be caused by this: ServicePath="~/Services/AutoCompleteNam e.asmx"
    in the video source code it is ServicePath="Au toCompleteName. asmx", but
    I've created a subfolder for my .asmx files just in case my project will
    have more .asmx files. I thought it was a nice way of keeping the project
    tidy, not having everything in the root folder.....
    >
    any suggestions?
    >
    Don't you need to uncomment the ScriptService attribute?

    --

    Joe Fawcett (MVP - XML)


    Comment

    • Jeff

      #3
      Re: Trouble using AutoCompleteExt ender

      thanks that solved the problem


      Comment

      Working...