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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:52:00+00:00 2026-06-02T07:52:00+00:00

I am using JQuery UI Autocomplete with an ASP.NET Textbox to populate the label

  • 0

I am using JQuery UI Autocomplete with an ASP.NET Textbox to populate the label as well as the value. Here is where i map the data from an ajax call:

success: function (data) {
    response($.map(data, function (item) {
        return {
            label: item.label,
            value: item.value
        }
    }));
}

The label is the text, the value is a number used to identify that row. My problem is when the user selects an option, the textbox replaces the label with the value. So if they select ‘John Smith’, the textbox changes from ‘John Smith’ to ‘1234’, etc. How can I manipulate the select event to leave the text in the textbox? Any help is appreciated. Thanks!

Here is a more complete view of my aspx page:

    <div class="ui-widget">
        <asp:TextBox ID="txbSearchKeyword" runat="server" Columns="50" />
    </div>
    <asp:HiddenField ID="selectedRecordId" runat="server" />

and the Jquery:

(function () {
    $("#txbSearchKeyword").autocomplete
    ({
        source:
            function (request, response) {
                $.ajax({
                    type: "POST",
                    url: "AutoComplete.asmx/GetAutoCompleteList",
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify({ keywordStartsWith: request.term }),
                    dataType: "json",
                    success: function (data) {
                        response($.map(data.d, function (item) {
                            return {
                                label: item.label,
                                value: item.value
                            }
                        }));
                    }
                });
            },
        minLength: 2
    });

    $("#txbSearchKeyword").autocomplete
    ({
        select: function (event, ui) {
            $('#selectedRecordId').val(ui.item.value);
            DoSomethingwithdataAJAXfunction(ui.item.value);
        }
    });
})();
  • 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-02T07:52:02+00:00Added an answer on June 2, 2026 at 7:52 am

    Perhaps some of this snippet will help you:

    select: function(event, ui) {
        var hasValue = (ui.item.value != undefined && ui.item.value != "" && ui.item.value != null);
        if (hasValue) {
            var focusedElement = $(this);
            focusedElement.val(ui.item.label);
            return false;
        }
        else {
            return false;
        }
    },
    focus: function(event, ui) {
        return false; // return "true" will put the value (label) from the selection in the field used to type
    },
    

    As an aside, I do not know why you have things separated when:

    minLength: 2
     });
      $("#txbSearchKeyword").autocomplete
     ({ 
        select:...
    

    could simply be:

    minLength: 2,
    select:...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Has anyone used jQuery to populate an autocomplete list on a textbox using ASP.NET
I'm using jquery ajax to fetch data from an asp.net webservice. I'm wondering how
Im trying to implement an asp.net textbox using the jQuery UI Autocomplete widget http://jqueryui.com/demos/autocomplete/#remote
i am using JQuery UI Autocomplete with asp.net textbox. AutoComplete works right. but how
I am using jQuery UI Autocomplete plugin for better data input in my ASP.NET
Using ASP.NET MVC, I've implemented an autocomplete textbox using the approach very similar to
Im using jquery autocomplete can I pass extraParams to webservice in asp.net ? and
I'm using asp.NET MVC, and am looking at the JQuery autocomplete plugin for what
I am using jQuery UI Autocomplete with ASP.NET like this : First I am
I'm using ASP .NET MVC2 and jquery UI Autocomplete. Sometimes application runs in Samsung

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.