dhoni kholi

dhoni kholi

  • NA
  • 198
  • 39.3k

Autocomplete textbox not working Asp.net

Dec 18 2019 6:01 AM
My Code
 
This Part Working Properly
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.Services;  
  6. using System.Data.SqlClient;  
  7. using System.Configuration;  
  8. using System.Web.Script.Services;  
  9. namespace Product  
  10. {  
  11. /// <summary>  
  12. /// Summary description for CustService  
  13. /// </summary>  
  14. [WebService(Namespace = "http://tempuri.org/")]  
  15. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]  
  16. [System.ComponentModel.ToolboxItem(false)]  
  17. // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.  
  18. [System.Web.Script.Services.ScriptService]  
  19. public class CustService : System.Web.Services.WebService  
  20. {  
  21. [WebMethod]  
  22. [ScriptMethod(ResponseFormat = ResponseFormat.Json)]  
  23. public List<string> GetAutoCompleteData(string name)  
  24. {  
  25. List<string> result = new List<string>();  
  26. using (SqlConnection con = new SqlConnection(@"Data Source=KARUKUVELRAJ-PC\SQLEXPRESS;Initial Catalog=Product;Integrated Security=True"))  
  27. {  
  28. using (SqlCommand cmd = new SqlCommand("select DISTINCT name from customer where name LIKE '%'+@SearchText+'%'", con))  
  29. {  
  30. con.Open();  
  31. cmd.Parameters.AddWithValue("@SearchText", name);  
  32. SqlDataReader dr = cmd.ExecuteReader();  
  33. while (dr.Read())  
  34. {  
  35. result.Add(dr["name"].ToString());  
  36. }  
  37. return result;  
  38. }  
  39. }  
  40. }  
  41. }  
  42. }  
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
</asp:ScriptManager>
<asp:TextBox ID="txtName" runat="server" Font-Bold="False" CssClass="form-control"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" ServiceMethod="GetAutoCompleteData" CompletionInterval="10" EnableCaching="False" TargetControlID="txtName" ServicePath="~/CustService.asmx"> </ajaxToolkit:AutoCompleteExtender>
 
I Run This Code Not invoke it not Response, How to Clear this Problem

Answers (4)