Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 75413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:30:44+00:00 2026-05-10T20:30:44+00:00

I searched all over this site and the web for a good and simple

  • 0

I searched all over this site and the web for a good and simple example of autocomplete using jQuery and ASP.NET. I wanted to expose the data used by autocomplete with a webservice (and will probably do that next). In the meantime, I got this working, but it seems a little hacky…

In my page I have a text box:

<input id='txtSearch' type='text' /> 

I am using jQuery autocomplete, set up per their example:

<link rel='stylesheet' href='js/jquery.autocomplete.css' type='text/css' /> <script type='text/javascript' src='js/jquery.bgiframe.js'></script> <script type='text/javascript' src='js/jquery.dimensions.pack.js'></script> <script type='text/javascript' src='js/jquery.autocomplete.js'></script> 

Here is where it starts to get hacky… I call a page instead of a webservice:

  <script type='text/javascript'>     $(document).ready(function(){         $('#txtSearch').autocomplete('autocompletetagdata.aspx');     });         </script> 

In the page I stripped out ALL of the html and just have this (otherwise, various HTML bits show up in the autocomplete dropdown):

<%@ Page Language='C#' AutoEventWireup='true' CodeFile='autocompletetagdata.aspx.cs' Inherits='autocompletetagdata' %> 

And in my autocompletetagdata.aspx, I am using SubSonic to query, format and return data from the database (one data item per line):

protected void Page_Load(object sender, EventArgs e) {     // Note the query strings passed by jquery autocomplete:     //QueryString: {q=a&limit=150&timestamp=1227198175320}      LookupTagCollection tags = Select.AllColumnsFrom<LookupTag>()         .Top(Request.QueryString['limit'])         .Where(LookupTag.Columns.TagDescription).Like(Request.QueryString['q'] + '%')         .OrderAsc(LookupTag.Columns.TagDescription)         .ExecuteAsCollection<LookupTagCollection>();      StringBuilder sb = new StringBuilder();      foreach (LookupTag tag in tags)     {         sb.Append(tag.TagDescription).Append('\n');     }      Response.Write(sb.ToString()); } 

If you don’t do a LIKE query, then it returns everything that contains a match for the character(s) you type — e.g., typing ‘a’ will include ‘Ask’ and ‘Answer’ as well as ‘March’ and ‘Mega.’ I just wanted it to do a starts with match.

Anyway, it works and it’s pretty easy to set up, but is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:30:45+00:00Added an answer on May 10, 2026 at 8:30 pm

    I just recently implemented autocomplete, and it looks fairly similar. I’m using an ashx (Generic Handler) instead of the aspx, but it’s basically the same code in the code behind.

    Using the ashx, it’ll look something like this:

    <script type='text/javascript'>   $(document).ready(function(){       $('#txtSearch').autocomplete('autocompletetagdata.ashx');   });       </script>  [WebService(Namespace = 'http://www.yoursite.com/')] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class AutocompleteTagData : IHttpHandler {     public void ProcessRequest(HttpContext context)     {         // Note the query strings passed by jquery autocomplete:         //QueryString: {q=a&limit=150&timestamp=1227198175320}          LookupTagCollection tags = Select.AllColumnsFrom<LookupTag>()             .Top(context.Request.QueryString['limit'])             .Where(LookupTag.Columns.TagDescription).Like(context.Request.QueryString['q'] + '%')             .OrderAsc(LookupTag.Columns.TagDescription)             .ExecuteAsCollection<LookupTagCollection>();          foreach (LookupTag tag in tags)         {             context.Response.Write(tag.TagDescription + Environment.NewLine);         }     }      public bool IsReusable     {         get         {             return false;         }     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer A few years back I had the same kind of… May 11, 2026 at 12:39 pm
  • added an answer Yes you can if: All the tables support it, (InnoDB… May 11, 2026 at 12:39 pm
  • added an answer It's a javascript snippet trying to exploit a security vulnerability… May 11, 2026 at 12:39 pm

Related Questions

I've searched the web a bit, but all I found were abandoned projects and
I've have searched on this and it seems to be a catch all, unfortunately
I have a form that searches all rows in a single table (TServices) that
I searched for this subject on Google and got some website about an experts
First let me say that I really feel directionless on this question. I am
This will require a little setup. Trust me that this is for a good
Whenever I try to write graphical programs (whether a game or really any GUI
Today I needed to parse some data out from an xlsx file (Office open

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.