Hi,
I was trying to disabling the holidays and weekends in my calender.I was tried the below code and additional some code to achieve the purpose.This will disable all weekends and holidays in the current month(say July).And also will disable all weekends in the next month(say august).But it is not disabling holiday lists in the next month after changing the month to July to august.For example i need to disable 25-Dec-2012 in my calender.How can do that? After changing the month the event "OnDayRender" not firing and disabling the days.Please help me?
I was trying to disabling the holidays and weekends in my calender.I was tried the below code and additional some code to achieve the purpose.This will disable all weekends and holidays in the current month(say July).And also will disable all weekends in the next month(say august).But it is not disabling holiday lists in the next month after changing the month to July to august.For example i need to disable 25-Dec-2012 in my calender.How can do that? After changing the month the event "OnDayRender" not firing and disabling the days.Please help me?
<%@ Page Language="C#" %> | ||||||||||||||
<%@ Import Namespace="System.Data" %> | ||||||||||||||
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> | ||||||||||||||
<script runat="server"> | ||||||||||||||
protected void Page_Load(object sender, EventArgs e) | ||||||||||||||
{ | ||||||||||||||
bool IsAlreadyLoaded = false; | ||||||||||||||
if (!Page.IsPostBack) | ||||||||||||||
{ | ||||||||||||||
} | ||||||||||||||
if (!IsAlreadyLoaded) | ||||||||||||||
{ | ||||||||||||||
Raddatepicker2.Calendar.SpecialDays.Clear(); | ||||||||||||||
Raddatepicker2.SelectedDate = DateTime.Now; | ||||||||||||||
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 otherMonthCssClass = "rcOutOfRange"; | ||||||||||||||
e.Cell.Text = ""; | ||||||||||||||
e.Cell.CssClass = "rcOutOfRange"; | ||||||||||||||
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); | ||||||||||||||
} //Checking for holidays if(e.Day.Date==HolidayDate) {
} |
||||||||||||||
} | ||||||||||||||
</script> | ||||||||||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||||||||||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||||||||||||||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||||||||||||||
<head runat="server"> | ||||||||||||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | ||||||||||||||
<title>RadControls for ASP.NET AJAX</title> | ||||||||||||||
</head> | ||||||||||||||
<body> | ||||||||||||||
<form id="form1" runat="server"> | ||||||||||||||
<asp:ScriptManager ID="ScriptManager1" runat="server" /> | ||||||||||||||
<script type="text/javascript"> | ||||||||||||||
function OnDayRender(calendarInstance, args) | ||||||||||||||
{ | ||||||||||||||
var jsDate = new Date(args._date[0], args._date[1] - 1, args._date[2]); | ||||||||||||||
if (jsDate.getDay() == 0 || jsDate.getDay() == 6) { | ||||||||||||||
var otherMonthCssClass = "rcOutOfRange"; | ||||||||||||||
args.get_cell().className = otherMonthCssClass; | ||||||||||||||
args.get_cell().innerHTML = "<span>" + args._date[2] + "</span>"; | ||||||||||||||
args.get_cell().DayId = ""; | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
</script> | ||||||||||||||
<telerik:RadDatePicker ID="Raddatepicker2" Skin="Office2007" Width="200px" MinDate="2009-01-01" | ||||||||||||||
runat="server" MaxDate="2099-12-16"> | ||||||||||||||
<DateInput ID="DateInput1" DateFormat="d" runat="server"> | ||||||||||||||
</DateInput> | ||||||||||||||
<Calendar ID="Calendar1" DayNameFormat="FirstTwoLetters" FirstDayOfWeek="Monday" | ||||||||||||||
runat="server" OnDayRender="Calendar_OnDayRender" Skin="Office2007"> | ||||||||||||||
<ClientEvents OnDayRender="OnDayRender" /> | ||||||||||||||
</Calendar> | ||||||||||||||
</telerik:RadDatePicker> | ||||||||||||||
</form> | ||||||||||||||
</body> | ||||||||||||||
</html> |