Hello,
I would like to limit the selectable dates in a calendar to only be the 2nd and 4th tuesdays of each month. I was able to set this in the server side ondayrender event by using the code below, however I am still able to select days that I added to the special days collection. The other issue is recreating this functionality in the client side ondayrender event. If there is a better way to go about doing this I am all ears.
Thanks,
Kirk
I would like to limit the selectable dates in a calendar to only be the 2nd and 4th tuesdays of each month. I was able to set this in the server side ondayrender event by using the code below, however I am still able to select days that I added to the special days collection. The other issue is recreating this functionality in the client side ondayrender event. If there is a better way to go about doing this I am all ears.
Thanks,
Kirk
protected void Calendar_OnDayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e) { DateTime dt = new DateTime(); dt = e.Day.Date; string month = RadCalendar1.CalendarView.TitleContent; month = month.Substring(0, month.Length - 5); System.Globalization.DateTimeFormatInfo info = new System.Globalization.DateTimeFormatInfo(); string[] monthNames; monthNames = info.MonthNames; if (dt.DayOfWeek == DayOfWeek.Monday && monthNames[dt.Month - 1] == month) { dayCount = dayCount + 1; if (dayCount != 2 && dayCount != 4) { RadCalendarDay calendarDay = new RadCalendarDay(); calendarDay.Date = e.Day.Date; calendarDay.IsSelectable = false; calendarDay.IsDisabled = true; RadDatePicker1.Calendar.SpecialDays.Add(calendarDay); e.Cell.BackColor = System.Drawing.Color.Gray; e.Cell.Text = "<span>" + e.Day.Date.Day + "</span>"; e.Cell.ID = ""; e.Cell.ControlStyle.CssClass = "disabledDay"; } } else { RadCalendarDay calendarDay = new RadCalendarDay(); calendarDay.Date = e.Day.Date; calendarDay.IsSelectable = false; calendarDay.IsDisabled = true; RadDatePicker1.Calendar.SpecialDays.Add(calendarDay); e.Cell.BackColor = System.Drawing.Color.Gray; e.Cell.Text = "<span>" + e.Day.Date.Day + "</span>"; e.Cell.ID = ""; e.Cell.ControlStyle.CssClass = "disabledDay"; } }