dhoni kholi

dhoni kholi

  • NA
  • 198
  • 43.3k

Autocomplete textbox Nothing Happen

Feb 8 2020 2:39 AM
Hi  everyone,
 
This my Code when i run it Nothing Happen
 
  1. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>  
  2. <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">  
  3.   
  4. </asp:Content>  
  5. <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">  
  6.  <div id="page-wrapper" >  
  7.          <div class="col-md-12">  
  8.   <!-- Form Elements -->  
  9.          <div class="panel panel-info">  
  10.          <div class="panel-heading">  
  11.                <h3 style="text-shadow: 2px 2px #79aed8;">PRODUCT ENTRY</h3>    
  12.           </div>  
  13.           <div class="panel-body">  
  14.           <table>    
  15.                 <tr>    
  16.                     <td>    
  17.                         <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True"></asp:ScriptManager>  
  18.                         <asp:Label ID="lblEmployee" Text="Employee Search" runat="server"></asp:Label>    
  19.                     </td>    
  20.                     <td>    
  21.                         <asp:TextBox ID="txtPcode" runat="server" Width="200" placeholder="Employee Name"></asp:TextBox>    
  22.                         <ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtPcode" ServiceMethod="getname" EnableCaching="True" MinimumPrefixLength="1" CompletionInterval="10" CompletionSetCount="1"> </ajaxToolkit:AutoCompleteExtender>  
  23.                     </td>    
  24.                 </tr>    
  25.             </table>    
  26.             </div>  
  27.           </div>  
  28.          </div>  
  29.       </div>  
  30. </asp:Content>  
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.UI;  
  6. using System.Web.UI.WebControls;  
  7. using System.Data;  
  8. using System.Configuration;  
  9. using System.Data.SqlClient;  
  10. using System.Web.Script.Services;  
  11. using System.Web.Services;  
  12.   
  13. namespace Product  
  14. {  
  15.     public partial class WebForm1 : System.Web.UI.Page  
  16.     {  
  17.         protected void Page_Load(object sender, EventArgs e)  
  18.         {  
  19.   
  20.         }  
  21.         [ScriptMethod()]  
  22.         [WebMethod]  
  23.         public static List<string> getname(string name)  
  24.         {  
  25.             SqlConnection con;  
  26.             SqlCommand cmd;  
  27.   
  28.             con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbcon1"].ConnectionString);  
  29.             cmd = new SqlCommand();  
  30.             cmd.Connection = con;   
  31.   
  32.             con.Open();  
  33.             string query = "select * from Product where subhead like '%'+ @searchname +'%'";  
  34.             cmd = new SqlCommand(query, con);  
  35.             cmd.Parameters.AddWithValue("@searchname", name);  
  36.             SqlDataAdapter sda = new SqlDataAdapter(cmd);  
  37.             DataTable dt = new DataTable();  
  38.             sda.Fill(dt);  
  39.   
  40.             List<string> names = new List<string>();  
  41.             for (int i = 0; i < dt.Rows.Count; i++)  
  42.             {  
  43.                 names.Add(dt.Rows[i][i].ToString());  
  44.             }  
  45.             return names;  
  46.         }  
  47.     }  
  48. }  
Please help me to how to implement auto complete textbox
 
Thanks .... 
 
 

Answers (2)