473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using jquery autocomplete from database in asp.net - couldn't get minLength working

Hi,

I want to use jquery autocomplete from database in asp.net. I got it working except the minLength option. As shown in the following code, I tried a few ways but couldn't get minLength option working. Please shed light on this. Thank you.

Here is my code:
Expand|Select|Wrap|Line Numbers
  1.     <script src="../../../jquery/jquery-1.7.2.js" type="text/javascript"></script>
  2.     <script type="text/javascript" src="../../../jquery/jquery.autocomplete.js"></script>
  3.       <script type="text/javascript">
  4.           $(document).ready(function() {
  5. //          $(".selector").autocomplete({ minLength: 0 });
  6. //          $(".selector").autocomplete("option", "minLength", 4); 
  7.           $("#<%=TextBox1.ClientID%>").autocomplete({ minLength: 4 });
  8.           $("#<%=TextBox1.ClientID%>").autocomplete("option", "minLength", 4); 
  9.           $("#<%=TextBox1.ClientID%>").autocomplete("AutocompleteData.ashx");
  10. //              $("#<%=TextBox1.ClientID%>").autocomplete({ source: "AutocompleteData.ashx", minLength: 4 });
  11.           });
  12.       </script> 
  13.  
Expand|Select|Wrap|Line Numbers
  1. <%@ WebHandler Language="C#" Class="AutocompleteData" %>
  2.  
  3. using System;
  4. using System.Web;
  5. using System.Data.SqlClient;
  6.  
  7. public class AutocompleteData : IHttpHandler {
  8.  
  9.     public void ProcessRequest(HttpContext context)
  10.     {
  11.         string schoolname = context.Request.QueryString["q"];
  12.         string sql = <my query>;
  13.         using (SqlConnection connection = new SqlConnection(
  14.             System.Configuration.ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString))
  15.         using (SqlCommand command = new SqlCommand(sql, connection))
  16.         {
  17.             connection.Open();
  18.             using (SqlDataReader reader = command.ExecuteReader())
  19.             {
  20.                 while (reader.Read())
  21.                 {
  22.                     context.Response.Write(reader.GetString(0) + Environment.NewLine);
  23.                 }
  24.             }
  25.         }
  26.     }
  27.  
  28.     public bool IsReusable {
  29.         get {
  30.             return false;
  31.         }
  32.     }
  33. }
May 2 '12 #1
0 1872

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: muscha | last post by:
Hi, I'm trying to decide whether I should use Guid.NewGuid() to generate an ID or using database sequence. Is Guid.NewGuid() will return a unique number? The MSDN said that the probability of...
1
by: rocksoft | last post by:
Hi, i have devloping web application in Asp.net and c#, i have used ajax to achieve the auto complete text box, my company using visual studio 2003, ajax auto complete text box...
2
by: Steve | last post by:
I have a new database created in Access 2007. Things were going swimmingly (or as well as they do for an amateur like me) when suddenly calculated fields on a form started giving me "?Name# as...
10
rizwan6feb
by: rizwan6feb | last post by:
Hi I have created a tabbed interface using jQuery using the code below <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">...
0
by: zeckdude | last post by:
Hi, I am having some issues with my site. I have a main Nav with four links that load in 4 different sections. You can see the page I am working on here:...
4
by: pavanip | last post by:
Hi, I want to popup aspx page using jquery. I have written the following code <a href="Contactus.aspx?TB_iframe=true&height=250&width=200" class="thickbox" >AboutUs</a> I have called...
1
by: puneetmca | last post by:
hi...this code of deleting a record from database using checkbox is not working...echo "<td>$row</td>; echo "<td>$row</td>"; echo "<td>$row....these lines print as it is...rather then...
1
by: empiresolutions | last post by:
After much research i understand that Safari isn't able to call the onClick Event like the other browsers do. So how do i get Safari to act like the other browsers is my question? I have see no real...
9
by: dexter delleva | last post by:
please can anyone help me? im currently working in a project and i already made a code for the login, the only thing is that i dont know how to update the records(Username/Password) in access using...
1
by: apssiva | last post by:
Hello All, 1. First i select the class name in combo box -> using jQuery reload the page. 2. after reload the page, Student name was display in random. so i add two radio button. 1....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.