I'm working on a custom calendar control that contains a RadCalendar. The control is being used to display a monthly school calendar that shows in-session days, holidays, vacation days, etc. I need to be able to add these items dynamically from codebehind so I can add text and color code the items, etc. I'm using the ITemplate interface to add CalendarDayTemplates as described in this post.
Unfortunately, I've run into what appears to be a bug. Accessing the calendar's CalendarView.ViewStartDate or CalendarView.ViewEndDate properties from the calendar's Init event completely breaks calendar navigation. I have tried adding the CalendarDayTemplates in the calendar's Prerender event but it appears that this is too late in the control's lifecyle as I get the following exception:
Server Error in '/' Application.
Exception Details: System.Exception: Template with ID: 02202012 not found.
If have confirmed that the issue is not with my code by stripping out everything but code that accesses CalendarView.ViewStartDate or CalendarView.ViewEndDate properties.
Here's how to reproduce the problem:
aspx code:
codebehind:
When running this, note that you can only move one month forward and one month back from the current month. Attempting to navigate additional months has no effect. Looking at FireBug's script tag show no errors.
The very bad news is that I was close to 2 days into working on getting this working and styled when I discovered this problem. Any suggestions or word arounds would be VERY appreciated.
Thanks -- Steve
Unfortunately, I've run into what appears to be a bug. Accessing the calendar's CalendarView.ViewStartDate or CalendarView.ViewEndDate properties from the calendar's Init event completely breaks calendar navigation. I have tried adding the CalendarDayTemplates in the calendar's Prerender event but it appears that this is too late in the control's lifecyle as I get the following exception:
Server Error in '/' Application.
Template with ID: 02202012 not found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Exception: Template with ID: 02202012 not found.
If have confirmed that the issue is not with my code by stripping out everything but code that accesses CalendarView.ViewStartDate or CalendarView.ViewEndDate properties.
Here's how to reproduce the problem:
aspx code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default2.aspx.cs" Inherits="NLGOnLineTestClient.default2" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
/>
<
telerik:RadCalendar
ID
=
"RadCalendar1"
runat
=
"server"
AutoPostBack
=
"True"
oninit
=
"RadCalendar1_Init"
>
</
telerik:RadCalendar
>
</
div
>
</
form
>
</
body
>
</
html
>
codebehind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace NLGOnLineTestClient
{
public partial class default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadCalendar1_Init(object sender, EventArgs e)
{
string range = string.Format("Start: {0} End {1}", RadCalendar1.CalendarView.ViewStartDate.ToString("g"), RadCalendar1.CalendarView.ViewEndDate.ToString("g"));
System.Diagnostics.Debug.WriteLine(range);
}
}
}
When running this, note that you can only move one month forward and one month back from the current month. Attempting to navigate additional months has no effect. Looking at FireBug's script tag show no errors.
The very bad news is that I was close to 2 days into working on getting this working and styled when I discovered this problem. Any suggestions or word arounds would be VERY appreciated.
Thanks -- Steve