I am using radcombobox in my project, I want to know how do I get the Keypress event of the Radcombobox as I want, when user selects the value from radcombo and hits the Enter Key from keyboard then it should work as same as when user presses select button.
Please reply as early as possible.
4 Answers, 1 is accepted
Try attaching OnClientKeyPressing client side event which occurs when a combobox receives the focus and the user presses a key. Try the following approach.
|<telerik:radcombobox id="RadComboBox1" AllowCustomText="true" runat="server" OnClientKeyPressing="HandkeKeyPress">|
|<telerik:RadComboBoxItem runat="server" Text="Item1" Value="Item1"></telerik:RadComboBoxItem>|
|<telerik:RadComboBoxItem runat="server" Text="Item2" Value="Item2"></telerik:RadComboBoxItem>|
|<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Select" />|
|function HandkeKeyPress(sender, eventArgs)|
|if (eventArgs.get_domEvent().keyCode == 13)|
|protected void Button2_Click(object sender, EventArgs e)|
The code you have provided is very useful for me.
I have a strange problem. I have a couple of items in combobox that has & in the text. When the combobox item is posted back, it resolves & to & and my feature fails. Any clues?
One strange thing is it resolves & for text only. In OldText value of the item it comes with &
RadComboBox uses HtmlEncode internally to encode Items' Texts and there is no way to turn this off.
If you insist on having the HTML entity instead of the decoded character, I can suggest two options for you:
Option 1: To implement your custom encoding method, see HttpUtility.HtmlEncode Method. With this encoding method, you can turn the HTML entity "&" to character "&" and vice versa right before your application uses it.
Option 2: Using templates. RadComboBox has no control over the Controls inside the Templates, so you may need to implement this approach and have the values presented as they are initially defined. Here is a forum topic discussing the same issue: Turn off html encode.
For more information on templates, please check out the following articles:
I hope that will help.
Our thoughts here at Progress are with those affected by the outbreak.