How to display only current month dates in Event calendar
This article provides you with a sample code which will hide the dates from other months. In the event calendar will be displayed only days and dates of currently selected month.
Please find the ascx file of the Event Calendat web part -
\CMSWebParts\Events\EventCalendar.ascx and make this change (marked bold):
<cms:CMSCalendar ID="calItems" runat="server" OnDayRender="calItems_DayRender">
Then please open the code behind file and add this code:
protected void calItems_DayRender(object sender, DayRenderEventArgs e)
{
if (this.calItems.VisibleDate != DateTimeHelper.ZERO_TIME)
{
if (e.Day.Date.Month != this.calItems.VisibleDate.Month)
{
e.Cell.Text = "";
}
}
else
{
if (e.Day.Date.Month != this.calItems.TodaysDate.Month)
{
e.Cell.Text = "";
}
}
}Applies to: Kentico CMS 3.x