RadDatePicker: Open popup on pressing F4

6 posts, 2 answers
  1. RvdGrint
    RvdGrint avatar
    112 posts
    Member since:
    May 2011

    Posted 14 Oct 2011 Link to this post

    Hello,

    is it possible top open the calender on pressing function key F4 when cursor is in DateInput field of the RadDatePicker control?
    I've tried to catch the key pres with ClientEvent OnKeyPress but this doesn't catch pressig F4.

    Can someone help me?

    Regards,
      Jos Meerkerk
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Oct 2011 Link to this post

    Hello Jos,

    I also tried the same scenario and was able to open the PopUp in FireFox in the KeyPress event.

    Javascript:
    function OnKeyPress(Sender, args)
    {
        var c = args.get_keyCode();
        if (c == 115)//key code of f4
          {
               var rdpkr1 = $find('DatePicker1');
               rdpkr1.showPopup();
           }
     
       }

    The following code helped me to work the same thing in IE as well.

    Javascript:
    document.onkeydown = function ()
     {
        if (window.event && window.event.keyCode == 115)
          {
               window.event.keyCode = 000;
               alert("Function key pressed!")
               var datePicker = $find('<%=DatePicker1.ClientID%>');
               datePicker.showPopup();
               return false;
           }
     }

    Hope it helps.

    Thanks,
    Princy.
  3. RvdGrint
    RvdGrint avatar
    112 posts
    Member since:
    May 2011

    Posted 14 Oct 2011 Link to this post

    Princy,

    the IE solution doesn't fit for me. I've several RadDatePickers on my user control. Catching the function key at document level is not enough because at that level I do not know which RadDatePicker the action should be applied to.

    Regards,
      Jos Meerkerk
  4. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Oct 2011 Link to this post

    Hello Jos,

    You can check whether the control is focused or not.
    C#:
    if (datePicker.get_dateInput()._isInFocus)
       {
           datePicker.showPopup();
       }

    Thanks,
    Princy.
  5. RvdGrint
    RvdGrint avatar
    112 posts
    Member since:
    May 2011

    Posted 17 Oct 2011 Link to this post

    Princy,

    any idea how to insert this from the code-behind of a dynamically loaded user control??
    I tried with clienscript.registerstartupscript but that doesn't work.

    Regards,
      Jos Meerkerk
  6. RvdGrint
    RvdGrint avatar
    112 posts
    Member since:
    May 2011

    Posted 17 Oct 2011 Link to this post

    Princy,

    I've added the script to the responsescript of the RadAjaxPanel and it worked. Thnx.
    If there's a beter solution please let me know.

    Regards,
      Jos Meerkerk
Back to Top