Solved

Autocomplete Extender Problem

Posted on 2009-07-07
2
678 Views
Last Modified: 2012-08-14
I am having a problem getting an autocomplete extender to work in asp.net.  Below is the code that I am attempting as a test to get it working.  Currently, nothing happens when text is entered into the text box.:

=================
Autocomplete.asmx:
=================
<%@ WebService Language="VB" Class="Names" %>

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<WebService(Namespace := "http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _  
Public Class Names
    Inherits System.Web.Services.WebService
   
    <WebMethod()> _
    Public Function Names(ByVal prefixText As String, ByVal count As Integer) As String()
        Dim list As New List(Of String)
        For i = 1 To 5
            list.Add(prefixText & " - " & i)
        Next
        Return list.ToArray
    End Function
End Class

=================
Search.aspx:
=================
...
Test: <asp:TextBox ID="TEST" runat="server" />

 <cc1:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="TEST" ServiceMethod="Names" ServicePath="Autocomplete.asmx" MinimumPrefixLength="2" CompletionInterval="1000" EnableCaching="true" CompletionSetCount="20" DelimiterCharacters=";, :" ShowOnlyCurrentWordInCompletionListItem="true"></cc1:AutoCompleteExtender>
...

Thanks in advance for any assistance you can offer!
0
Comment
Question by:jayh99
2 Comments
 
LVL 1

Accepted Solution

by:
jayh99 earned 0 total points
ID: 24798245
I found the issue, in the Autocomplete.asmx, i needed to include the following line to allow it to be called from a script:

<System.Web.Script.Services.ScriptService()> _

Autocomplete.asmx:
 

<%@ WebService Language="VB" Class="Names" %>
 

Imports System.Web

Imports System.Web.Services

Imports System.Web.Services.Protocols
 

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.

' <System.Web.Script.Services.ScriptService()> _

<WebService(Namespace:="http://tempuri.org/")> _

<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _

<System.Web.Script.Services.ScriptService()> _

Public Class Names

    Inherits System.Web.Services.WebService

    

    <WebMethod()> _

    Public Function Names(ByVal prefixText As String, ByVal count As Integer) As String()

        Dim list As New List(Of String)

        For i = 1 To 5

            list.Add(prefixText & " - " & i)

        Next

        Return list.ToArray

    End Function

End Class

Open in new window

0
 
LVL 20

Expert Comment

by:ddayx10
ID: 24798334
LOL I was just getting ready to post on this. You didn't need to add it, you just needed to uncomment it about 4 lines up from where you added it.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now