<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> <services> <asp:ServiceReference Path="~/AutoComplete.asmx" /> </services> <asp:TextBox ID="TxtCompName" Width="350px" runat="server" AutoPostBack="True" ontextchanged="TxtCompName_TextChanged"/> <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" CompletionListItemCssClass="autocomplete_listItem" CompletionListCssClass="autocomplete_completionListElement" Enabled="True" ServiceMethod="GetCompletionList" ServicePath="~/AutoComplete.asmx" TargetControlID="TxtCompName" UseContextKey="True" CompletionInterval="100" DelimiterCharacters="" CompletionSetCount="20" MinimumPrefixLength="1" />
[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.Web.Script.Services.ScriptService] public class AutoComplete : System.Web.Services.WebService { public AutoComplete() { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public static string[] GetCompletionList(string prefixText, string contextKey) { SqlConnection conn; SqlCommand cmd; string cmdString = "SELECT comp_name FROM tbl_admin_Brand WHERE comp_name LIKE'" + prefixText + "%'"; conn = new SqlConnection("Data Source=INDIA\\SQLEXPRESS;Initial Catalog=BrandMutual;User ID=sa1;Password=123"); cmd = new SqlCommand(cmdString, conn); conn.Open(); SqlDataReader myReader; List<string> returnData = new List<string>(); myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (myReader.Read()) { returnData.Add(myReader["comp_name"].ToString()); } return returnData.ToArray(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)