Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

auto complete extender did not work in asp.net 4.5

$
0
0

Hi,

Please, can anyone give me idea or help me out why my auto complete extender is not working.

Thanks in advanced.

Here is my Frontend and ASMX


 <ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajax:ToolkitScriptManager>

 <asp:TextBox ID="txtIng1" runat="server" CssClass="ddlbranch textboxradiuscolor" Width="250" Height="20"></asp:TextBox>  

 <ajax:AutoCompleteExtender ID="AutoCompleteExtender2" runat="server" TargetControlID="txtIng1"
                                                                MinimumPrefixLength="1" ServiceMethod="getProductList"
                                                                CompletionInterval="1000" ServicePath="~/WebServices/InvProduct.asmx"
                                                                CompletionSetCount="20" DelimiterCharacters=";, :"
                                                                ShowOnlyCurrentWordInCompletionListItem="true"
                                                                OnClientItemSelected="OnContactSelected"
                                                                CompletionListCssClass="completionlist" CompletionListHighlightedItemCssClass="completionlisthighlight"
                                                                CompletionListItemCssClass="completionlistitem">
 </ajax:AutoCompleteExtender>

using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;


namespace POS.WebServices
{
    /// <summary>
    /// Summary description for InvProduct
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
    // 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 InvProduct : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod(EnableSession = true)]
        public string[] getProductList(string prefixText, int count)
        {
            string status = Session["status"].ToString();
            string constatus = Session["conStatus"].ToString();
            SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings[constatus]);

            //ADO.Net         
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();

            //     con.ConnectionString = strCn;
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandType = CommandType.Text;

            //prevent SQL injection--------//
            cmd.CommandText = "select * from Inv_Product Join Branch b on b.BranchId= Inv_Product.BranchId Where InvProductName like @myParameter and Inv_Product.DeleteStatus = 'N' and b.DeleteStatus = 'N'";
            cmd.Parameters.AddWithValue("@myParameter", "%" + prefixText + "%");

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds);
            }
            catch
            {
            }
            finally
            {
                con.Close();
            }
            dt = ds.Tables[0];

            //Then return List of string(txtItems) as result
            List<string> txtItems = new List<string>();
            String dbValues;

            foreach (DataRow row in dt.Rows)
            {
                //String From DataBase(dbValues)
                dbValues = row["InvProductName"].ToString();
                dbValues = dbValues.ToLower();
                txtItems.Add(dbValues);
            }

            return txtItems.ToArray();
        }
    }
}


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>