Telerik RadCalendar provides a collection of dynamic templates that customize the presentation of calendar days on a "per day" basis. The templates can contain regular HTML and are particularly useful if you want to implement a scheduler-like interface with extra information, such as images illustrating events, links to additional sources, etc.

To implement Day Templates you need to perform the following steps:
-
Define the individual DayTemplate in the CalendarDayTemplates collection - you need to create individual templates for each different type of day you need to customize. Below is an example of a few day templates:
| ASPX |
Copy Code |
|
<CalendarDayTemplates> <rad:DayTemplate ID="dayTemplate1"> <Content> <img src="Img/birthday.gif" alt="event icon" /> </Content> </rad:DayTemplate> <rad:DayTemplate ID="dayTemplate2"> <Content> 10.00 AM<BR />Sales Team Presentation </Content> </rad:DayTemplate> </CalendarDayTemplates> |
-
Assign the Day Templates to RadCalendarDay objects in the SpecialDays collection - each of this objects which template corresponds to the respective date. The items are comprised of the following elements: the
appearance template (DisplaySettingsID), the day template (TemplateID), the Date (Date), and the repeatable argument (Repeatable). Below is an example of a few special day definitions:
| ASPX |
Copy Code |
|
<SpecialDays> <rad:RadCalendarDay TemplateID="dayTemplate1" Repeatable="DayInMonth" Date="2005-11-01"></rad:RadCalendarDay> <rad:RadCalendarDay TemplateID="dayTemplate2" Repeatable="DayInMonth" Date="2005-11-03"></rad:RadCalendarDay> <rad:RadCalendarDay TemplateID="dayTemplate3" Repeatable="DayInMonth" Date="2005-11-04"></rad:RadCalendarDay> </SpecialDays> |
-
Dynamically add Special Days - the following code example shows how you can add dynamically Special Days to Telerik RadCalendar:
| C# |
Copy Code |
|
private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { //creating the day instance RadCalendarDay NewDay = new RadCalendarDay(Radcalendar2);
//setting the visual settings for this special day NewDay.ItemStyle.CssClass = "radCalToday_Default";
// we will use this special day to mark today's date NewDay.Repeatable = RecurringEvents.Today;
// we add the special day only once (on first accessing the page), as later // it gets persisted through the viewstate.
Radcalendar2.SpecialDays.Add(NewDay); } } |
See Also