/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); CalendarView.SelectionChanged += new EventHandler(CalendarView_SelectionChanged); CalendarView.DayRender += new DayRenderEventHandler(CalendarView_DayRender); CalendarView.VisibleMonthChanged += new MonthChangedEventHandler(CalendarView_VisibleMonthChanged); if (!IsPostBack) { // Default begin date is todays date. CalendarList.BeginDate = DateTime.Now; CalendarList.DataBind(); // MonthlyItems is a hidden calendar list used to calculate what days to highlight in CalenderView. // We use the first of current month as begin date but substract 6 days since CalendarView can show up to 6 days of previous month. MonthlyItems.BeginDate = new DateTime(CalendarView.TodaysDate.Year, CalendarView.TodaysDate.Month, 1).AddDays(-6); // NumberOfDaysToRender is calculated to 6 + 31 + 13 = 50. // 6 = CalendarView can show up to 6 days of previous month. // 31 = Maximum number of days in a month. // 13 = CalendarView can show up to 13 days of next month. MonthlyItems.NumberOfDaysToRender = 50; MonthlyItems.DataBind(); } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!IsPostBack) { EnableViewMode(); EditCalendarBox.Text = CurrentPage.PageName; DeleteCalendarSectionLinkButton.OnClientClick = string.Format("if(!confirm('{0}'))return false;", Translate("/common/messages/confirmdelete")); // Default begin date is todays date. CalendarList.BeginDate = DateTime.Now; CalendarList.DataBind(); // MonthlyItems is a hidden calendar list used to calculate what days to highlight in CalenderView. // We use the first of current month as begin date but substract 6 days since CalendarView can show up to 6 days of previous month. MonthlyItems.BeginDate = new DateTime(CalendarView.TodaysDate.Year, CalendarView.TodaysDate.Month, 1).AddDays(-6); // NumberOfDaysToRender is calculated to 6 + 31 + 13 = 50. // 6 = CalendarView can show up to 6 days of previous month. // 31 = Maximum number of days in a month. // 13 = Calenda rView can show up to 13 days of next month. MonthlyItems.NumberOfDaysToRender = 50; MonthlyItems.DataBind(); } CalendarView.SelectionChanged += new EventHandler(CalendarView_SelectionChanged); CalendarView.DayRender += new DayRenderEventHandler(CalendarView_DayRender); CalendarView.VisibleMonthChanged += new MonthChangedEventHandler(CalendarView_VisibleMonthChanged); }
private void CalendarView_DayRender(object sender, DayRenderEventArgs e) { TableCell cell = e.Cell; cell.HorizontalAlign = HorizontalAlign.NotSet; if (e.Day.IsToday) { cell.CssClass += " today"; } if (MonthlyItems.DateIsActive(e.Day.Date)) { cell.CssClass += " active"; //cell.ForeColor = ColorTranslator.FromHtml("#ffffff"); } }