I've got a combobox that I want to place focus into the box and have it ready for a person to enter in the next item after they hit the add button. So, the person starts typing the item information, and it finds the match in the drop down, they hit tab and enter to add the item, and the focus then needs to go back to the textbox for them to enter the next item. However, I don't want to clear out the entry of the combobox.
Originally, I was calling combo.focus in the code behind. That seems to set the focus correctly, but it could place the cursor at the beginning or the end and doesn't select all the text for them to be able to simply start typing again. I've resorted to use this code instead:
It appears to be working, but I just want to know if there is a better method for doing this or if what I have is the best route to go down.
Thanks,
Adam
Originally, I was calling combo.focus in the code behind. That seems to set the focus correctly, but it could place the cursor at the beginning or the end and doesn't select all the text for them to be able to simply start typing again. I've resorted to use this code instead:
ajxManager.ResponseScripts.Add(
"$find('"
& cboFrom.ClientID &
"').get_inputDomElement().focus();$find('"
& cboFrom.ClientID &
"').selectText(0, $find('"
& cboFrom.ClientID &
"').get_text().length);"
)
It appears to be working, but I just want to know if there is a better method for doing this or if what I have is the best route to go down.
Thanks,
Adam