Hi ,
I try to implement the sample http://www.telerik.com/community/code-library/aspnet-ajax/calendar/disabling-calendar-days.aspx ti disable the weekend day.
But the result is very strange. He don't disable the weekend days but the 4 days of the first week and 3 day on the last week.
I say that the sample was from 2007 (little bit old ;-) ) and it was needed to change little think (like i found in other post).
But this change don't solve my problem.
Any issue would be appreciate.
Thanks
Edwin.
Here my code:
I try to implement the sample http://www.telerik.com/community/code-library/aspnet-ajax/calendar/disabling-calendar-days.aspx ti disable the weekend day.
But the result is very strange. He don't disable the weekend days but the 4 days of the first week and 3 day on the last week.
I say that the sample was from 2007 (little bit old ;-) ) and it was needed to change little think (like i found in other post).
But this change don't solve my problem.
Any issue would be appreciate.
Thanks
Edwin.
Here my code:
| // necessary to disable the weekends on client-side navigation |
| function OnDayRender(calendarInstance, args) { |
| // convert the date-triplet to a javascript date |
| // we need Date.getDay() method to determine |
| // which days should be disabled (e.g. every Saturday (day = 6) and Sunday (day = 0)) |
| var jsDate = new Date(args._date[0], args._date[1] - 1, args._date[2]); |
| if (jsDate.getDay() == 0 || jsDate.getDay() == 6) { |
| var otherMonthCssClass = "otherMonth_" + calendarInstance.Skin; |
| args.Cell.className = otherMonthCssClass; |
| // replace the default cell content (anchor tag) with a span element |
| // that contains the processed calendar day number -- necessary for the calendar skinning mechanism |
| args.Cell.innerHTML = "<span>" + args._date[2] + "</span>"; |
| // disable selection and hover effect for the cell |
| args.Cell.DayId = ""; |
| } |
| } |
| <telerik:RadDatePicker ID="Raddatepicker2" Style="vertical-align: middle;" Skin="Office2007" Width="200px" |
| MinDate="2009-01-01" runat="server" MaxDate="2099-12-16" Culture="Dutch (Netherlands)"> |
| <DateInput onclick="ToggleSecondPopup()" DateFormat="d" runat="server"></DateInput> |
| <Calendar DayNameFormat="FirstTwoLetters" FirstDayOfWeek="Monday" runat="server" OnDayRender="Calendar_OnDayRender" Skin="Office2007" DisabledDayStyle-ForeColor="Gray"> |
| <ClientEvents OnDayRender="OnDayRender" /> |
| </Calendar> |
| </telerik:RadDatePicker> |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if(!Page.IsPostBack) |
| { |
| } |
| if(!IsAlreadyLoaded) |
| { |
| Raddatepicker2.Calendar.SpecialDays.Clear(); |
| Raddatepicker2.SelectedDate = DateTime.Now; |
| FullPage(); |
| FullUpdate(); |
| IsAlreadyLoaded = true; |
| } |
| } |
| protected void Calendar_OnDayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e) |
| { |
| if(e.Day.Date.DayOfWeek == DayOfWeek.Saturday || e.Day.Date.DayOfWeek == DayOfWeek.Sunday) |
| { |
| string calendarSkin = Raddatepicker2.Calendar.Skin != "" ? Raddatepicker2.Calendar.Skin : "Default"; |
| string otherMonthCssClass = String.Format("otherMonth_{0}", calendarSkin); |
| e.Cell.Text = ""; |
| e.Cell.CssClass = otherMonthCssClass; |
| Label label = new Label(); |
| label.Text = e.Day.Date.Day.ToString(); |
| e.Cell.Controls.Add(label); |
| RadCalendarDay calendarDay = new RadCalendarDay(); |
| calendarDay.Date = e.Day.Date; |
| calendarDay.IsSelectable = false; |
| calendarDay.ItemStyle.CssClass = otherMonthCssClass; |
| Raddatepicker2.Calendar.SpecialDays.Add(calendarDay); |
| } |
| } |
