here my textbox not autocomplete it shows no error why.........
Search.ashx
<%@ WebHandler Language="C#" Class="Search" %>
using System;
using System.Web;
using System.Text;
using System.Data.SqlClient;
public class Search : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string searchText = context.Request.QueryString["q"];
SqlConnection con = new SqlConnection("Data Source=GETDES_06;Initial Catalog=prakash;User ID=sa;Password=sql@2012");
con.Open();
SqlCommand cmd = new SqlCommand("Select username,imagename from getezee where username Like @Search + '%'", con);
cmd.Parameters.AddWithValue("@Search", searchText);
StringBuilder sb = new StringBuilder();
using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
sb.Append(string.Format("{0},{1}{2}", dr["username"], dr["imagename"], Environment.NewLine));
}
}
con.Close();
context.Response.Write(sb.ToString());
}
public bool IsReusable
{
get
{
return false;
}
}
}
asp.code
<script src="scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="scripts/jquery.autocomplete.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("<%#txtSearch.ClientID%>").autocomplete("Search.ashx", {
width: 200,
formatItem: function (data, i, n, value) {
return "<img style = 'width:50px;height:50px' src= userimage/" + value.split(",")[1] + "'/> " + value.split(",")[0];
},
formatResult: function (data, value) {
return value.split(",")[0];
}
});
});
</script>
<div class="auto-style8">
<asp:TextBox ID="txtSearch" runat="server" CssClass="style16" Height="25px" placeholder="Search your idea" Width="314px" ></asp:TextBox>
<asp:Button ID="bt1" runat="server" Text="Search" Height="32px" CssClass="style16" BackColor="#CC9900" Width="74px" OnClick="bt1_Click" />
</div>