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

  • SEARCH
  • Home
  • 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 8143925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:14:24+00:00 2026-06-06T13:14:24+00:00

I have a ASP.NET textbox autocomplete with JQuery, is working perfectly, i type part

  • 0

I have a ASP.NET textbox autocomplete with JQuery, is working perfectly, i type part of the person name and displays the list with all the possible options, but now i want that when i search the name shows me on the list of results the email address next to the name, the names and emails are on a SQL database, i want that when i type John i get the list with

John Andrews John@email.com

John Smith Smith@email.com

And so on… this is the code:

  <%@ WebHandler Language="C#" Class="Search_CS" %>
    using System;
    using System.Web;
    using System.Data.SqlClient;
    using System.Configuration;
    using System.Text;

    public class Search_CS : IHttpHandler {

    public void ProcessRequest (HttpContext context) {
        string prefixText = context.Request.QueryString["q"];
        using (SqlConnection conn = new SqlConnection())
        {
            conn.ConnectionString = ConfigurationManager
                    .ConnectionStrings["constr"].ConnectionString;
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.CommandText = "select * from directory where name like @SearchText + '%'";
                cmd.Parameters.AddWithValue("@SearchText", 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;
        }
    }
    }
  • 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. Editorial Team
    Editorial Team
    2026-06-06T13:14:25+00:00Added an answer on June 6, 2026 at 1:14 pm

    when your adding name to your string builder, also add the email.. this code should work

    while (sdr.Read())
    {
        sb.Append(sdr["name"] + " " + sdr['email']).Append(Environment.NewLine);
    }
    

    or

    while (sdr.Read())
    {
        sb.Append(sdr["name"])
        sb.Append(" ") //space between name and email
        sb.Append(sdr['email'])
        sb.Append(Environment.NewLine);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem while using jquery maskedinput with asp.net textbox. I have a check
Im trying to implement an asp.net textbox using the jQuery UI Autocomplete widget http://jqueryui.com/demos/autocomplete/#remote
I have made a textbox with an autocomplete in ASP.NET MVC 4, Javascript and
I have an asp.net textbox that is disabled: <asp:TextBox ID=txtEmpName runat=server Enabled=false></asp:TextBox> Using jQuery,
I have asp.net TextBox with ontextchanged event this is search text box in my
I have an asp.net TextBox in which I want to check if the text
I have a asp.net web content from that have a asp.net textbox and I
the problem is that I do have an ASP.NET TextBox in a FormView with
I am attaching an asp.net textbox image I want my textbox should have two
i have an asp.net form and an asp:textbox. i have a problem when the

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.