Click here to Skip to main content
15,877,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Could you please help me in highlighting the typed words in the auto complete text box. i am already populating the auto-complete words and i need to just highlight the typed words alone.i am new to Jquery auto-complete.

My code is:

<script type="text/javascript">
    $(document).ready(function () {
    function SearchText() {
            source: function (request, response) {
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "Default.aspx/GetAutoCompleteData",
                    data: "{'username':'" + document.getElementById('txtSearch').value + "'}",
                    dataType: "json",
                    success: function (data) {

                    error: function (result) {

public static List<string> GetAutoCompleteData(string username)
    List<string> result = new List<string>();
    using (SqlConnection con = new SqlConnection("Data Source=;Initial Catalog=StockImageBank2014Apr;User ID=sa;password=sib"))
        using (SqlCommand cmd = new SqlCommand("select top (10) SubCategory from PhotographySubCategory where SubCategory LIKE '%'+@SearchText+'%'", con))
            cmd.Parameters.AddWithValue("@SearchText", username);
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            return result;
Updated 27-Aug-14 0:19am

1 solution

Share this answer
@p@richit 27-Aug-14 5:43am    
Thanks for reply @Tadit ,but i can't able to understand the refered code. i am new in jquery. can you please help for the given code.
Rajeev did you read that answer? There is also an demo link. Go to that. You can see the code also.
@p@richit 28-Aug-14 0:09am    
I have tried.when i populate that code,auto-complete not working
Do you see any errors in console window of developer tool?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900