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

Call Button Click Event On Hitting Enter Key

2 Answers 1284 Views
Input
This is a migrated thread and some comments may be shown as answers.
Mallikharjun Mulagundla
Top achievements
Rank 1
Mallikharjun Mulagundla asked on 08 Nov 2010, 12:44 PM
Hi,

I've got a 3 RadTextBoxs(RadNumericTextBox) and 3 buttons beside that. I wanted to fire the Button1 click event on Hitting Enter key of 1st TextBox. similarly, fire Button2 click event on hitting Enter key on 2nd TextBox. Could you help me to resolve this issue.

Thanks, Malli

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Nov 2010, 01:43 PM
Hello,

The following code snippet shows how to trigger the button's click event when the Enter key is pressed inside the text box.

JavaScript:
function OnKeyPress(sender, args)
   {
       if (args.get_keyCode() == 13)
       {
           document.getElementById('Button1').click();
           args.set_cancel(true);        
       }
   }

ASPX:
<telerik:radtextbox id="txtEmail" runat="server" tabindex="1">
       <ClientEvents OnKeyPress="OnKeyPress" />
        
</telerik:radtextbox>
 
<asp:Button ID="Button1" runat="server" Text="Button"  OnClientClick="OnClientClick1();" />

Thanks,
Princy.
0
Princy
Top achievements
Rank 2
answered on 08 Nov 2010, 01:44 PM
.
Tags
Input
Asked by
Mallikharjun Mulagundla
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or