Delete and Backspace key is not triggering Key events

3 posts, 1 answers
  1. Priyakant
    Priyakant avatar
    5 posts
    Member since:
    Nov 2010

    Posted 15 Aug 2011 Link to this post

    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. Answer
    Miroslav Nedyalkov
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 19 Aug 2011 Link to this post

    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.

    Miroslav Nedyalkov
    the Telerik team

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

  3. DevCraft banner
  4. Priyakant
    Priyakant avatar
    5 posts
    Member since:
    Nov 2010

    Posted 19 Aug 2011 Link to this post

    We tried your solution and it do work.

    Thanks for your quick response.

Back to Top