Hi,
I would like to get some feedback on the recommended way to disable MarkFirstMatch through Javascript.
My situation is this: I have a load-on-demand combo box MarkFirstMatch = true to allow the users to have autocomplete capability. However, the combo itself will allow custom text. We just ran into a situation where the user attempted to enter an item that begins with the same letters as an existing item, but the combo would not allow the text truncation. For example, the combo has "Principal Software Developer", but the user just wanted to enter "Principal", and the combo box would automatically complete with "Software Developer". Pressing backspace would delete the "Software Developer" only temporarily, and it would re-appear as you navigated to another control.
Anyway, I fixed it by adding the following javascript code in the OnKeyPressing event of the combo box:
(Note: In the above code block, "markFirstMatch" begins with underscore)
The above code traps the backspace key, and when pressed, disables the MarkFirstMatch property of the calling combo box. If the user starts to type anything else, it turns it back on.
This seems to work fine, but I am a little uneasy relying on an undocumented javascript property. Is there a better way to do this?
Thanks,
--Brad
I would like to get some feedback on the recommended way to disable MarkFirstMatch through Javascript.
My situation is this: I have a load-on-demand combo box MarkFirstMatch = true to allow the users to have autocomplete capability. However, the combo itself will allow custom text. We just ran into a situation where the user attempted to enter an item that begins with the same letters as an existing item, but the combo would not allow the text truncation. For example, the combo has "Principal Software Developer", but the user just wanted to enter "Principal", and the combo box would automatically complete with "Software Developer". Pressing backspace would delete the "Software Developer" only temporarily, and it would re-appear as you navigated to another control.
Anyway, I fixed it by adding the following javascript code in the OnKeyPressing event of the combo box:
function rdlKeyPressing(sender, eventArgs) { |
if (eventArgs.get_domEvent().keyCode == 8) { |
sender._markFirstMatch = false; //This allows users to enter values not in combo, but shortened versions of existing items. |
} else { |
sender._markFirstMatch = true; |
} |
} |
The above code traps the backspace key, and when pressed, disables the MarkFirstMatch property of the calling combo box. If the user starts to type anything else, it turns it back on.
This seems to work fine, but I am a little uneasy relying on an undocumented javascript property. Is there a better way to do this?
Thanks,
--Brad