This question is locked. New answers and comments are not allowed.
How do you implement the "@(Html.Telerik().DatePickerFor" control and disable specific dates so the user doesn't select it from the calendar?
The model has a property called "RangeOfDueDates List<PaymentDueDate>" which I want to bind it to. The PaymentDueDate object has 3 properties: DueDate (DateTime), DueDateString (string) , EnableDate (bool).
I want to somehow iterate through the dates in the telerik Date Picker control and disable the date if the EnableDate property in the list is set to false.
I have searched every where and saw a non-mvc3 solution to this problem and was wondering if I could create an Extension Method to do more or less the same thing as this:
The model has a property called "RangeOfDueDates List<PaymentDueDate>" which I want to bind it to. The PaymentDueDate object has 3 properties: DueDate (DateTime), DueDateString (string) , EnableDate (bool).
I want to somehow iterate through the dates in the telerik Date Picker control and disable the date if the EnableDate property in the list is set to false.
I have searched every where and saw a non-mvc3 solution to this problem and was wondering if I could create an Extension Method to do more or less the same thing as this:
protected void Calendar_OnDayRender(object sender, Telerik.WebControls.Base.Calendar.Events.DayRenderEventArgs e) { // modify the cell rendered content for the days we want to be disabled (e.g. every Saturday and Sunday) if (e.Day.Date.DayOfWeek == DayOfWeek.Saturday || e.Day.Date.DayOfWeek == DayOfWeek.Sunday) { // if you are using the skin bundled as a webresource("Default"), the Skin property returns empty string string calendarSkin = RadDatePicker1.Calendar.Skin != "" ? RadDatePicker1.Calendar.Skin : "Default"; string otherMonthCssClass = String.Format("otherMonth_{0}", calendarSkin); // clear the default cell content (anchor tag) as we need to disable the hover effect for this cell e.Cell.Text = ""; e.Cell.CssClass = otherMonthCssClass; //set new CssClass for the disabled calendar day cells (e.g. look like other month days here) // render a span element with the processed calendar day number instead of the removed anchor -- necessary for the calendar skinning mechanism Label label = new Label(); label.Text = e.Day.Date.Day.ToString(); e.Cell.Controls.Add(label); // disable the selection for the specific day RadCalendarDay calendarDay = new RadCalendarDay(); calendarDay.Date = e.Day.Date; calendarDay.IsSelectable = false; calendarDay.ItemStyle.CssClass = otherMonthCssClass; RadDatePicker1.Calendar.SpecialDays.Add(calendarDay); } }