Disabling dates in calendar

5 posts, 0 answers
  1. Kevin
    Kevin avatar
    58 posts
    Member since:
    May 2009

    Posted 09 Jun 2009 Link to this post

    Hi i need to be able to disable dates in a calendar based on an if statement which would pass a value in

    dates would be along these lines
    1 day
    3 days
    a week
    10 days
    20 days
    24 days
    a month
    many thanks
  2. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 09 Jun 2009 Link to this post

    Hello Kevin,

    For more information about how to disable calendar days, please refer to the following article:
    Code Library

    Greetings,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Kevin
    Kevin avatar
    58 posts
    Member since:
    May 2009

    Posted 09 Jun 2009 Link to this post

    Hi Pavlina

    the example doesnt cover what i need to do with the control i need to enable and disable days based on if they are in the if statement im writing it seems that the code covers a certain day IE saturday or sunday


    Thanks
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Jun 2009 Link to this post

    Hi Kevin,

    You may try the following code snippet to disable a set of Dates in the given date range.

    CS:
     
    protected void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e) 
        { 
            
            DateTime StartDate = Convert.ToDateTime("06/11/2009"); 
            DateTime EndDate = Convert.ToDateTime("06/15/2009"); 
            if (e.Day.Date >= StartDate.Date && e.Day.Date <= EndDate.Date) 
            { 
     
                // disable the selection for the specific day 
                RadCalendarDay calendarDay = new RadCalendarDay(); 
                calendarDay.Date = e.Day.Date; 
                calendarDay.IsSelectable = false
                RadCalendar1.SpecialDays.Add(calendarDay); 
            } 
     
        } 


    Thanks
    Shinu
  5. Kevin
    Kevin avatar
    58 posts
    Member since:
    May 2009

    Posted 15 Jun 2009 Link to this post

    Thanks Shinu that has wored a treat however there is another question i would like to ask how do i make my days that i need to use a different colour im currently using this code
    if (current <= end)  
    {  
    currentCell = a.Cell;  
    currentCell.Style["background-color"] = backgroundColor;  
    currentCell.Visible = true;  
    any ideas?
Back to Top