Date picker - Hot key for current day

2 posts, 0 answers
  1. vamshi
    vamshi avatar
    3 posts
    Member since:
    Aug 2010

    Posted 10 May 2011 Link to this post

    HI ,
    Good Evenning!!

    I have an requirement in my project. when we enter 'today'  or 'c' in date picker , needs to show 'Current date' ( say May 10th).

    please hlep me with code part.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 May 2011 Link to this post

    Hello Vamshi,

    The RadDatePicker provides a rich client side API. You can attach the onKeyPress and set the date accordingly.
    aspx:
    <telerik:RadDatePicker ID="DatePicker1" runat="server">
           <DateInput ClientEvents-OnKeyPress="OnKeyPress" ></DateInput>
    </telerik:RadDatePicker>

    Javascript:
    function OnKeyPress(Sender, args)
      {
            if (args.get_keyCharacter() == "c")
           {
                var datePicker = $find("<%= DatePicker1.ClientID %>");
                var date = new Date();
                date.setDate(date.getDate());
                datePicker.set_selectedDate(date);
            }
      }

    Also take a look at the following documentation.
    RadDatePicker Client Object

    Thanks,
    Princy.
Back to Top