Click here to Skip to main content
15,991,108 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
I am having the foll0wing issue with this....

This is my scenario:
- Using AJAX ComboBox
- Set AutoComplete to Append
- Set AutoPostBack to True
- Set DropDownStyle to DropDownList

What I am trying to do:
I have a combobox with a list of employees which upon typing the first few letters of the name and when I HIT ENTER not SELECT the name, I would like the employee info to update in my Formview. This works fine if I SELECT the name, however not when I hit Enter.

In doing some research I have come to learn that Tabbing out of the combobox will cause the SelectedIndexChanged procedure to fire, which is fine by me, HOWEVER, I cannot get the act of hitting the ENTER key to mimic the act of hitting the TAB key.

This is what i have tried and it does not work

VB Code
Page Load

VB
Me.ComboBox_Guest.Attributes.Add("onkeydown", "return SetNextControlFocus(event,'" + TextBox1.ClientID + "')")


ASP
Script
JavaScript
function SetNextControlFocus(e, controlclientid) {

        var evt = e ? e : window.event;
        var ctrl = document.getElementById(controlclientid);

        if (ctrl) {
            if (evt.keyCode == 9) {
                ctrl.focus();
                return false;
            }
            else {
                if (evt.keyCode == 13) {
                    ctrl.focus();
                    return false;
                }
                else {
                    return true;
                }
            }
        }
        else {
            return true;
        }
    }


Your assistance is greatly appreciated
Posted
Updated 20-Mar-12 9:39am
v2
Comments
Sergey Alexandrovich Kryukov 20-Mar-12 15:41pm    
Why would you artificially shift focus at all? It rarely makes sense, maybe sometimes, for initial focus. Later all, UI itself shifts focus where the user wants. You probably prevent it...
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900