This is a migrated thread and some comments may be shown as answers.

Keypress Event of Radcombo box

4 Answers 404 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
rahul
Top achievements
Rank 1
rahul asked on 23 May 2009, 05:22 AM
HI..
     
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.
      Thank You.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 May 2009, 04:56 AM
Hello Rahul,

Try attaching OnClientKeyPressing client side event which occurs when a combobox receives the focus and the user presses a key. Try the following approach.

ASPX:
 
<telerik:radcombobox id="RadComboBox1" AllowCustomText="true" runat="server" OnClientKeyPressing="HandkeKeyPress">  
<Items> 
   <telerik:RadComboBoxItem runat="server" Text="Item1" Value="Item1"></telerik:RadComboBoxItem> 
   <telerik:RadComboBoxItem runat="server" Text="Item2" Value="Item2"></telerik:RadComboBoxItem> 
</Items> 
</telerik:radcombobox> 
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Select" /> 

JavaScript:
 
<script type="text/javascript">  
function HandkeKeyPress(sender, eventArgs)  
{  
   if (eventArgs.get_domEvent().keyCode == 13)  
   {  
      __doPostBack('Button2','');  
   }  
}  
</script> 

CS:
 
protected void Button2_Click(object sender, EventArgs e)  
{  
    Response.Write("Button click");  

-Princy.
0
rahul
Top achievements
Rank 1
answered on 25 May 2009, 05:40 AM
Thank You.
         The code you have provided is very useful for me.
0
M
Top achievements
Rank 1
answered on 08 Apr 2020, 06:50 PM

I have a strange problem. I have a couple of items in combobox that has &amp; in the text. When the combobox item is posted back, it resolves &amp; to & and my feature fails. Any clues?

One strange thing is it resolves &amp; for text only. In OldText value of the item it comes with &amp;

0
Doncho
Telerik team
answered on 10 Apr 2020, 04:20 PM

Hi,

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 "&amp;" 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.

Kind regards,
Doncho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
ComboBox
Asked by
rahul
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
rahul
Top achievements
Rank 1
M
Top achievements
Rank 1
Doncho
Telerik team
Share this question
or