Question

I am sure this is a simple solution, but I am at my end..

I have the following ASPX

      <asp:TextBox ID="textVendorNameLookup" AutoPostBack="true" runat="server" Width="200px" 
                    onFocus="this.select()" 
                    Text=''></asp:TextBox>
                <ajaxToolkit:AutoCompleteExtender ID="VendorNameAutoCompleteExtender" TargetControlID="textVendorNameLookup"
                    FirstRowSelected="false" runat="server" ServiceMethod="GetVendor" CompletionInterval="1" 
                    EnableCaching="true" MinimumPrefixLength="1" UseContextKey="true" ServicePath="VendorLookupWebService.asmx">

                </ajaxToolkit:AutoCompleteExtender>

And the following ASMX

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Xml;


/// <summary>
/// Summary description for VendorLookupWebService
/// </summary>
[WebService(Namespace = "http://rouses.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class VendorLookupWebService : System.Web.Services.WebService
{

    public VendorLookupWebService()
    {

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

    [WebMethod]
    //public string[] GetOrganization(string prefixText)
    public static List<String> GetVendor(string prefixText)
    {

        var cmdText = "Select vmvnnm from dbmoto..apvendp where vmvnnm like @prefixText and vmasts = 'A'";

        using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MAINConnectionString"].ToString()))
        using (var cmd = new SqlCommand(cmdText, conn))
        {
            cmd.Parameters.Add(new SqlParameter("@prefixText", string.Format("%{0}%", prefixText)));
            conn.Open();
            SqlDataReader dr = cmd.ExecuteReader();

            var Vendors = new List<string>();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Vendors.Add(dr["vmvnnm"].ToString());
                }
            }
            conn.Close();
            return Vendors;
        }

    }
}

But the webservice is not firing when I type into the textbox....

Any ideas?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top