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

RadDatePicker: Open popup on pressing F4

5 Answers 136 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
RvdGrint
Top achievements
Rank 1
RvdGrint asked on 14 Oct 2011, 10:59 AM
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

5 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 14 Oct 2011, 12:18 PM
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.
0
RvdGrint
Top achievements
Rank 1
answered on 14 Oct 2011, 12:29 PM
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
0
Accepted
Princy
Top achievements
Rank 2
answered on 17 Oct 2011, 09:20 AM
Hello Jos,

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

Thanks,
Princy.
0
RvdGrint
Top achievements
Rank 1
answered on 17 Oct 2011, 07:55 PM
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
0
RvdGrint
Top achievements
Rank 1
answered on 17 Oct 2011, 08:34 PM
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
Tags
Calendar
Asked by
RvdGrint
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
RvdGrint
Top achievements
Rank 1
Share this question
or