SelectableDateStart behavior

2 posts, 1 answers
  1. Alex
    Alex avatar
    25 posts
    Member since:
    Mar 2011

    Posted 14 Sep 2013 Link to this post

    Hi there!
    I have a calendar and I'm setting SelectableDateStart  and SelectableDateEnd

    If I set SelectableDateEnd using following code:
    SelectableDateEnd = new DateTime(2013, 10, 6);
    then I can select 6th of October

    If I set SelectableDateEnd using following code:
    SelectableDateEnd = new DateTime(2013, 10, 6, 11, 0, 0);
    then I cannot select 6th of October, only 7th.

    Please, explain why Calendar behaves like this.

    Thank you.
  2. Answer
    Todor avatar
    773 posts

    Posted 18 Sep 2013 Link to this post

    Hello Alex,

    Thank you for your question.

    If you set the SelectableDateEnd to either of the two values that you mentioned, the result is the same: 6th of October is the last selectable date and 7th is not selectable.

    I assume you mean that you want to change the SelectableDateStart. When you select a date in RadCalendar, its SelectedValue has the date that you selected but the time has its default value of 12:00 AM. This means that when you set you selectable dates range, the actually selectable values are the dates where 12:00 AM is included in the range.

    For example if you selectable range is defined like this:

    calendar.SelectableDateStart = new DateTime(2013, 10, 6, 11, 0, 0);
    calendar.SelectableDateEnd = new DateTime(2013, 10, 13, 11, 0, 0);

    Then 6th of October is not selectable, because the DateTime object (2013, 10, 6, 0, 0, 0), which would be the selected value if the date was selected, is out of the defined range.

    If you have another DateTime value that you want to use for the SelectableDateStart and you would like to have it included you can use its Date component only:

    calendar.SelectableDateStart = MyDateTimeValue.Date;

    If you have another scenario where it makes more sence to have the SelectableDateStart set to specific part of the day, please explain it in more details.

    I hope this information helps and now RadCalendar's behavior makes more sense.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
Back to Top