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 7060697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:23:01+00:00 2026-05-28T04:23:01+00:00

I have a text box, Inside I want it to auto complete. The data

  • 0

I have a text box,
Inside I want it to auto complete.
The data for the auto complete is going to be given through the database.

This is my Jquery:

 var data = "autocompletetagdata.aspx"
    $("#item").autocomplete({
        source: data
    });

This is what I have put in autocompletetagdata for now:

protected void Page_Load(object sender, EventArgs e)
{
    string term = Request.QueryString["term"];
   SqlConnection myConnection = new SqlConnection(connStr);
   myConnection.Open();
   string SQL = ("select Top 10 LTRIM(RTRIM(PGPRDC)) As PGPRDC FROM SROPRG SROPRG");
   SqlCommand myCommand = new SqlCommand(SQL, myConnection);
   StringBuilder sb = new StringBuilder();
   try
      {
        SqlDataReader reader = myCommand.ExecuteReader();
        if (reader.HasRows)
        {
           while (reader.Read())
           {
             sb.Append(reader.GetString(0))
                           .Append(Environment.NewLine);
            }
        }
        reader.Close();
      }
   catch (Exception ex)
   {
      myConnection.Close();
   }
   myConnection.Close();
       Response.Write(sb.ToString());  
//return "['word', 'hello', 'work', 'oi', 'hey']";     
    } 

What am i doing wrong?

EDIT:

 <script type="text/javascript" src="/scripts/js/jquery.scrollTo-min.js"></script>
<script type="text/javascript" src="/scripts/js/jquery.flash.min.js"></script>
<script type="text/javascript" src="/scripts/js/jquery.sifr.min.js"></script>
<script type="text/javascript" src="/scripts/js/global.js"></script>
<script type="text/javascript" src="/scripts/js/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="/scripts/js/orderstatus.js"></script>    
<script type="text/javascript" src="/scripts/js/jquery.ui.core.js"></script>
<script type="text/javascript" src="/scripts/js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="/scripts/js/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="/scripts/js/jquery.qtip-1.0.0-rc3.min.js"></script>
<script type="text/javascript" src="/scripts/js/json_parse.js"></script>

When you go to autocompletetagdata..aspx in the browser you get back on the screen…

SC052 SC053 SC055 SC060 SC061 SC062 SC063 SG011 SG014 SG015

Firebug also does show these items being sent back in the response, but nothing happens to the text box

  • 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-05-28T04:23:02+00:00Added an answer on May 28, 2026 at 4:23 am

    This is Jquery Code :

    $("#txt1").autocomplete({
        source: function (request, response){
            $.ajax({
                type: "POST",                        
                url: "YourAddress",           
                contentType: "application/json; charset=utf-8",
                dataType: "json",                                                    
                success: function (data) {
                response($.map(data.d, function (item) {
                    return {
                        id: item.Value,
                        value: item.Text
                    }
                }))
            }
            });
        },
        select: function (event, ui) {
            $("#hdnId").val(ui.item.id);//Put Id in a hidden field
        }
    });
    

    call you ajax request and return JSON data something like this :

    [{"Value":val1,"Text":"text1"},
    {"Value":val2,"Text":"text2"}]
    

    for return somthing like that you must define a class like this :

    public class Autocomplete
    {
    
        private int val;
        private string text;
    
        public int Value
        {
            get
            {
                return val;
            }
            set
            {
    
                val = value;
            }
        }
    
        public string Text
        {
            get
            {
                return text;
            }
            set
            {
    
                text = value;
            }
        }
    }
    

    so it just enough to return a list of this class objects (List<Autocomplete>).So create this list and fill it by your sqlcommand and then return it as response of your XMLHTTPRequest

    I tested it.It works great man

    Good luck.Foroughi

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just want some direction really. Want my search box to have text inside, but
I have a text box that is going to be populated with a comma
I have a text-box, and I want to enter a string in language A
I have a text box on a web page, whose value I want to
What can I do if I want to have a text-box representing in real
In my ASP.NET page I have a text box which shows data which is
I have a control. It's a text box. I want to draw an image
I have a text box inside the modal popup. when a button is clicked
I have a text box inside the modal popup. when a button is clicked
I have a text box on a form and want to perform different actions

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.