using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Data; using System.Data.Sql; using AjaxControlToolkit; using DAL; namespace BAL { /// <summary> /// Summary description for WebService1 /// </summary> [WebService(Namespace = "http://testserver/webservices")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] //[System.Web.Services.WebMethod] //[System.Web.Script.Services.ScriptMethod] public class WebService1 : System.Web.Services.WebService { [WebMethod] public String[] GetCompanyList(String prefixText, Int32 count) { String[] strList = null; List<string> strCompanyList = new List<string>(); String Consigneeprefix = prefixText + "%"; String Sql = "SELECT TOP'"+count+"'[conCode],[conName] FROM [tblConsignee] WHERE [cusCode] ='"+webSupport.ShipperCode().Trim() +"' AND [conName] LIKE'" + Consigneeprefix +"'"; // webSupport.ShipperCode refer to get the ShipperCode for Sql Query String via. DataTable dt = new DataTable(); dt = SQLTrans.executeQuery(Sql, "tbl"); if (dt.Rows.Count> 0) { for ( int i = 0 ; i< dt.Rows.Count;i++) { // Here is the Douted area in web method. strCompanyList.Add(AjaxControlToolkit.AutoCompleteExtender. CreateAutoCompleteItem(dt.Rows[i][0].ToString(), Convert.ToString(dt.Rows[i][1].ToString()))); } strList = new String[10]; strList = strCompanyList.ToArray(); } else { //No records found } return strList; } } }
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <asp:TextBox ID="TextBox1" runat="server" Height="19px" Width="256px"></asp:TextBox> <asp:AutoCompleteExtender ID="txtAutoCompleteforCompany_AutoCompleteExtender" MinimumPrefixLength="1" TargetControlID="TextBox1" CompletionSetCount="10"CompletionInterval="100" ServiceMethod="GetCompanyList" ServicePath="../BAL/WebService1.asmx" runat="server" OnClientItemSelected="setCompanyMasterID" CompletionListElementID="listPlacement"> </asp:AutoCompleteExtender> </asp:Content>
CompletionSetCount="10"CompletionInterval="100"
CompletionSetCount="10" CompletionInterval="100"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)