locked
AutoComplete not working RRS feed

  • Question

  • User-741367366 posted

    Hey there, 

    start working with .net 4.5.1 and AjaxControlToolkit (installed by Nuget). 

    I created an example but it won't work, there is no firing of the web method.

    WebService File

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    
    namespace AutoComplete
    {
        /// <summary>
        /// Zusammenfassungsbeschreibung für AutoComplete
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]
        // Wenn der Aufruf dieses Webdiensts aus einem Skript mithilfe von ASP.NET AJAX zulässig sein soll, heben Sie die Kommentarmarkierung für die folgende Zeile auf. 
        // [System.Web.Script.Services.ScriptService]
        public class AutoComplete : System.Web.Services.WebService
        {
    
            [WebMethod]
            public List<string> GetStates(string prefixText, int count)
            {
                List<string> states = new List<string>() { "Alaska", "Alabama", "California", "North Dakota" };
    
                return states;
            }
    
        }
    }
    

    and the apsx

    <%@ Page Language="C#"  MasterPageFile="~/Site.Master"  AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="AutoComplete._Default" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    
        <asp:TextBox ID="txtStates" runat="server"></asp:TextBox>
        <ajaxToolkit:AutoCompleteExtender ID="autoCompleteStates" runat="server" 
          DelimiterCharacters="" Enabled="True" TargetControlID="txtStates" ServiceMethod="GetStates" 
            MinimumPrefixLength="1" ServicePath="~/AutoComplete.asmx" CompletionInterval="200">
        </ajaxToolkit:AutoCompleteExtender>
    </asp:Content>

    there no action, just nothing... 

    please help!

    Thursday, August 14, 2014 3:40 PM

Answers

  • User-417640953 posted

    Hi alexu14,

    Thanks for your post.

    According to your description and code provided, I see you want to use the AutoCompleteExtender and get data from

    asp.net web service. Based on the code, you should take note below points:

    # Uncomment the line below as other member mentioned.

    // Wenn der Aufruf dieses Webdiensts aus einem Skript mithilfe von ASP.NET AJAX zulässig sein soll, heben Sie die Kommentarmarkierung für die folgende Zeile auf. 
     [System.Web.Script.Services.ScriptService]
    

    # Make sure the path of the web service file .asmx correct.

     MinimumPrefixLength="1" ServicePath="~/AutoComplete.asmx" CompletionInterval="200">
    

    # There is a example for you AutoCompleteExtender works with asp.net web service.

    http://www.c-sharpcorner.com/UploadFile/munnamax/AutocompleteExtender08062007113854AM/AutocompleteExtender.aspx

    If has any doubt please feel free to back. Thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 20, 2014 5:54 AM

All replies

  • User-1360095595 posted

    You need to uncomment this line:

    // [System.Web.Script.Services.ScriptService]
    Thursday, August 14, 2014 3:42 PM
  • User-741367366 posted

    Thanks, but it doesn't changed anything.

    Thursday, August 14, 2014 4:20 PM
  • User-741367366 posted

    I was wrong, still nothing... whats wrong???

    Thursday, August 14, 2014 4:42 PM
  • User-417640953 posted

    Hi alexu14,

    Thanks for your post.

    According to your description and code provided, I see you want to use the AutoCompleteExtender and get data from

    asp.net web service. Based on the code, you should take note below points:

    # Uncomment the line below as other member mentioned.

    // Wenn der Aufruf dieses Webdiensts aus einem Skript mithilfe von ASP.NET AJAX zulässig sein soll, heben Sie die Kommentarmarkierung für die folgende Zeile auf. 
     [System.Web.Script.Services.ScriptService]
    

    # Make sure the path of the web service file .asmx correct.

     MinimumPrefixLength="1" ServicePath="~/AutoComplete.asmx" CompletionInterval="200">
    

    # There is a example for you AutoCompleteExtender works with asp.net web service.

    http://www.c-sharpcorner.com/UploadFile/munnamax/AutocompleteExtender08062007113854AM/AutocompleteExtender.aspx

    If has any doubt please feel free to back. Thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 20, 2014 5:54 AM