Need to get index of item in AutoCompleteExtender

Posted on 2009-04-22
Last Modified: 2012-05-06
I am just starting out in ajax.  I've figured out how to get the items I need to fill a list in the AutoExtendControl attached to a textbox.  That part works fine, and I'm able to enter text, see the drop-down, and then select an item to fill out the textbox.  But I am trying to find a quick way to access the index (integer) of the item selected from the list.  I need this in order to search a separate list for the same index in order to pull values into other places on the page.  
Question by:RinaX
    LVL 9

    Accepted Solution

    1: add hidden field next to your serach textbox
                        <asp:HiddenField ID="SelectedItemValue" runat="server" />
    2: register onchange event to your listbox
                         listbox.Attributes.Add("onchange", String.Format("javascript:SelectItem(this,  '{0}');", SelectedItemValue.ClientID);
    3: Create a javascript function where you copy the listbox selected value into the hidden field.
                         function SelectItem(listElement, hdnField)
                            document.getElementById(hdnField).value = listElement.options[listElement.selectedIndex].value

    then you should have the selected value in hidden field for later use.

    Hope this helps!

    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now