This is a migrated thread and some comments may be shown as answers.
Capture Enter Key RadDatePicker
2 Answers 50 Views
This is a migrated thread and some comments may be shown as answers.
kith
Top achievements
Rank 1
kith asked on 20 Dec 2010, 11:01 AM
Hello,

How do I capture "Enter Key" from keyboard in my RadDatePicker? I want to click an ASP Button when this event is triggered. I have the code below but it's not working. I'm using the latest version of Telerik. Any help is highly appreciated.

<telerik:raddatepicker id="RadDatePicker_EndUsage" runat="server" Width="62px" Culture="English (United States)" onkeydown="handleEnterEvent">
<Calendar id="Calendar2" runat="server" skin="Office2007" />
 <DateInput id="DateInput2" InvalidStyleDuration="100" skin="Office2007" runat="server">
    <ClientEvents OnFocus="ShowCalendar" />
</DateInput>
    <DatePopupButton Visible="False" />
</telerik:raddatepicker>

Javascript:

function handleEnterEvent(sender, e)
{
     e = e || window.event;
     if (e.keyCode == 13)
          $find("<%# processButton.ClientID %>").click();
}

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 20 Dec 2010, 01:27 PM
Hello Kith,

You can attatch the client event  OnKeyPress to the DateInput and try the following code to raise the Button Click event.

aspx:
<telerik:RadDatePicker ID="RadDatePicker1" runat="server" Width="62px" Culture="English (United States)  AutoPostBack="false">
      <Calendar ID="Calendar1" runat="server" Skin="Office2007" />
      <DateInput ID="DateInput1" InvalidStyleDuration="100" Skin="Office2007" runat="server">
         <ClientEvents OnKeyPress="handleEnterEvent" />
      </DateInput>
      <DatePopupButton Visible="False" />
</telerik:RadDatePicker>

JavaScript:
function handleEnterEvent(sender, args)
   {
       if (args.get_keyCode() == 13)
       document.getElementById("processButton").click();
   }

Regards,
Shinu.
0
kith
Top achievements
Rank 1
answered on 21 Dec 2010, 05:27 AM
Thanks Shinu! Works like a charm :)
Asked by
kith
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
kith
Top achievements
Rank 1
Share this question
or