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

Disabling dates in calendar

4 Answers 150 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 09 Jun 2009, 03:00 PM
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

4 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 09 Jun 2009, 03:32 PM
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.
0
Kevin
Top achievements
Rank 1
answered on 09 Jun 2009, 03:53 PM
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
0
Shinu
Top achievements
Rank 2
answered on 11 Jun 2009, 06:51 AM
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
0
Kevin
Top achievements
Rank 1
answered on 15 Jun 2009, 09:21 AM
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?
Tags
Calendar
Asked by
Kevin
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Kevin
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or