Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving a hard time with jquery autocomplete
    primarykey
    data
    text
    <p>I am absolutely new to jquery . But wanted to use it for a college project . I used a webservice .The values are retrieved from a SQL database. The code compiles without any error. But the autocomplete feature does not work.</p> <p>The code for the handler is given below:</p> <pre><code> &lt;%@ WebHandler Language="C#" Class="Handler" %&gt; using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Text; public class Handler : IHttpHandler { public void ProcessRequest(HttpContext context) { string prefixText = context.Request.QueryString["q"]; string constr = "Data Source=USER\\SQLEXPRESS;Initial Catalog=my_db;Integrated Security=True;"; using (SqlConnection conn = new SqlConnection(constr)) { // conn.ConnectionString = ConfigurationManager // .ConnectionStrings["constr"].ConnectionString; using (SqlCommand cmd = new SqlCommand(constr,conn)) { cmd.CommandText = "select [name] from names where " + "[name] like @SearchText + '%'"; cmd.Parameters.Add("@SearchText", SqlDbType.VarChar, 50).Value = prefixText + "%"; cmd.Connection = conn; StringBuilder sb = new StringBuilder(); conn.Open(); using (SqlDataReader sdr = cmd.ExecuteReader()) { while (sdr.Read()) { sb.Append(sdr["name"]) .Append(Environment.NewLine); } } conn.Close(); context.Response.Write(sb.ToString()); } } } public bool IsReusable { get { return false; } } } </code></pre> <p>the code for the scripting is given below:</p> <pre><code> &lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script src="scripts/jquery-1.7.2.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="scripts/jquery-1.7.2.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="scripts/jquery.ui.autocomplete.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="scripts/jquery.ui.core.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="scripts/jquery.ui.position.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="scripts/jquery.ui.widget.js" type="text/javascript"&gt;&lt;/script&gt; &lt;link href="scripts/demos.css" rel="stylesheet" type="text/css" /&gt;" &lt;script type="text/javascript"&gt; $(document).ready(function () { $("#&lt;%= txtsearch.ClientID %&gt;").autocomplete({ minLength: 1, delay: 0, "~/Handler.ashx"}); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;asp:TextBox ID="txtsearch" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Can someone tell me where i am comitting the mistake.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload