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

Delete and Backspace key is not triggering Key events

2 Answers 453 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Priyakant
Top achievements
Rank 1
Priyakant asked on 15 Aug 2011, 05:31 PM

We have a RadDatePicker that is used to gather a required field from the user.   We have also activated the field level notification to provide immediate feedback to the user as they are typing in the date.  We have tied into the ParseDateTimeValue event so we can set a flag indicating whether the TextToParse contains a valid or not, and this works almost flawlessly.  The one issue we have occurs when the user highlights the entire date in the text field and hits the DEL or Backspace key to delete the entire date.  In this particular instance no  ParseDateTimeValue event is not triggered, even though it is triggered for both DEL and Backspace when only part or none of the date text is selected.

 

As a workaround we attached a KeyDown event handler, but it is exhibiting the same behavior, it is properly triggered for all KeyDown events except when the entire date text is selected and the DEL or Backspace key is pressed.

 

Has anyone else encountered this behavior and/or have a way to correct or bypass it?

 

This was observed under Windows 7, IE 8.0.7601.17514 using C#.
Telerik Version: 2011.1.419.1040

2 Answers, 1 is accepted

Sort by
0
Accepted
Miroslav Nedyalkov
Telerik team
answered on 19 Aug 2011, 11:44 AM
Hi Priyakant,

 The RadDateTimePicker doesn't fire the ParceDateTimeValue only when the text is empty and this is intentional - the value for empty string is null. When DEL or Backspace keys are pressed and there is text left we are firing this event as expected.

In order to detect are this keys hit or not you should hook-up to the KeyDown routed event using the AddHandler method of the RadDateTimePicker control and setting the last parameter to true like this:

picker.AddHandler(KeyDownEvent, new KeyEventHandler(OnHandleKeyDown), true);
instead of hooking-up to the CLR event KeyDown. This will allow you to receive even the handle events like the ones that come from the TextBox.

Hope this helps.

Regards,
Miroslav Nedyalkov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Priyakant
Top achievements
Rank 1
answered on 19 Aug 2011, 03:53 PM
We tried your solution and it do work.

Thanks for your quick response.

-Priyakant
Tags
DateTimePicker
Asked by
Priyakant
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Priyakant
Top achievements
Rank 1
Share this question
or