How to highlight current date in DateTimePicker

7 posts, 1 answers
  1. Shashank
    Shashank avatar
    5 posts
    Member since:
    Feb 2009

    Posted 19 Feb 2009 Link to this post

    Hi,
    I want to higlight the current date in the rad date time picker,  if a user selects any other date, other than today, today's date should still be highlighted, while he selects other date of his desire. I want to higlight today's date, so that it serves as a reference to user, just in case he forgets what today';s date is. Please help.

    Thanks
    Shashank

  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Feb 2009 Link to this post

    Hi Shashank,

    Add SpecialDays as shown below in order to highlight current day in calendar popup of RadDateTimePiker.

    ASPX:

    <telerik:RadDateTimePicker ID="RadDateTimePicker1" Runat="server" Culture="English (United States)">  
    <Calendar> 
        <SpecialDays> 
            <telerik:RadCalendarDay Repeatable="Today" ItemStyle-BackColor="Bisque"/>  
        </SpecialDays> 
    </Calendar> 
    </telerik:RadDateTimePicker> 

    Thanks,
    Princy.

  3. Shashank
    Shashank avatar
    5 posts
    Member since:
    Feb 2009

    Posted 19 Feb 2009 Link to this post

    Thanks princy,
    works fine.

  4. Gregg
    Gregg avatar
    30 posts
    Member since:
    Sep 2007

    Posted 11 May 2009 Link to this post

    How do you achieve the same if the DateTimePicker is instead created by a GridDateTimeColumn? For example: 

    <telerik:GridDateTimeColumn
     PickerType="DateTimePicker"
    ...

  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 May 2009 Link to this post

    Hi Gregg,

    Try out the following code snippet in order to highlight current date.

    ASPX:

     
    <telerik:GridDateTimeColumn DataField="BirthDate" HeaderText="BirthDate" SortExpression="BirthDate" UniqueName="BirthDate" PickerType="DateTimePicker" DataType="System.DateTime">  
    </telerik:GridDateTimeColumn> 

    CS:
     
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
        {  
            GridDataItem dataItem = e.Item as GridDataItem;  
            RadDateTimePicker datepicker = (RadDateTimePicker)dataItem["BirthDate"].Controls[0];  
     
            RadCalendarDay NewDay = new RadCalendarDay();             
            NewDay.Repeatable = RecurringEvents.Today;              
            NewDay.ItemStyle.BackColor = System.Drawing.Color.Bisque;  
            datepicker.SharedCalendar.SpecialDays.Add(NewDay);           
        }  

    Thanks,
    Princy.

  6. Gregg
    Gregg avatar
    30 posts
    Member since:
    Sep 2007

    Posted 12 May 2009 Link to this post

    That works. Thank you.

  7. Ram
    Ram avatar
    97 posts
    Member since:
    Jun 2011

    Posted 15 Jul 2011 Link to this post

    Hi princy.
    I'm using Raddatetimepicker
    Can I acheive this in raddatetimepicker.
    Can I place the calender image inside textbox rightside as in my attached pic

Back to Top