i'm trying to restrict the dates that can be selected in a DatePicker control
Rather than set the disabled dates for the next x years i want to set the disabled dates for just the current month and update each time a user scrolls to the next/previous month. i've added a handler to the Scroll method and set the AutoPostbackOnScroll to true but the handler isn't called.
.aspx:
Quote:<%@ Page Language="C#" Trace="true" AutoEventWireup="true" CodeFile="EOCalendarTest.aspx.cs" Inherits="CalendarTest" %>
<%@ Register assembly="EO.Web" namespace="EO.Web" tagprefix="eo" %>
<!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">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<eo:DatePicker ID="DatePicker1" runat="server" ControlSkinID="None"
DayCellHeight="16" DayCellWidth="19" DayHeaderFormat="FirstLetter"
SelectedDates=""
TitleLeftArrowImageUrl="DefaultSubMenuIconRTL"
TitleRightArrowImageUrl="DefaultSubMenuIcon"
PickerFormat="dd/MM/yyyy" AutoPostbackOnScroll="True"
onscroll="DatePicker1_Scroll">
<TodayStyle CssText="font-family: tahoma; font-size: 12px; border-right: #bb5503 1px solid; border-top: #bb5503 1px solid; border-left: #bb5503 1px solid; border-bottom: #bb5503 1px solid" />
<SelectedDayStyle CssText="font-family: tahoma; font-size: 12px; background-color: #fbe694; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
<DisabledDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
<PickerStyle CssText="font-family:Courier New; padding-left:5px; padding-right: 5px;" />
<CalendarStyle CssText="background-color: white; border-right: #7f9db9 1px solid; padding-right: 4px; border-top: #7f9db9 1px solid; padding-left: 4px; font-size: 9px; padding-bottom: 4px; border-left: #7f9db9 1px solid; padding-top: 4px; border-bottom: #7f9db9 1px solid; font-family: tahoma" />
<TitleArrowStyle CssText="cursor:hand" />
<DayHoverStyle CssText="font-family: tahoma; font-size: 12px; border-right: #fbe694 1px solid; border-top: #fbe694 1px solid; border-left: #fbe694 1px solid; border-bottom: #fbe694 1px solid" />
<MonthStyle CssText="font-family: tahoma; font-size: 12px; margin-left: 14px; cursor: hand; margin-right: 14px" />
<TitleStyle CssText="background-color:#9ebef5;font-family:Tahoma;font-size:12px;padding-bottom:2px;padding-left:6px;padding-right:6px;padding-top:2px;" />
<OtherMonthDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
<DayHeaderStyle CssText="font-family: tahoma; font-size: 12px; border-bottom: #aca899 1px solid" />
<DayStyle CssText="font-family: tahoma; font-size: 12px; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
</eo:DatePicker>
</div>
</form>
</body>
</html>
.cs
Quote:using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class CalendarTest : System.Web.UI.Page
{
protected void DatePicker1_Scroll(object sender, EventArgs e)
{
//Doesn't fire
DatePicker1.DisabledDates.Add(new DateTime(2008, 10, 1));
}
}
So i decided to use a DayRender handler to modify the appearance of each day but it causes the following message to be displayed when trying to scroll to a different month.
Quote:EO.Web Controls Client Side Debug Message:
EO.Web control 'ctl03' error message:The callback on 'ctl03' has failed because the server did not recognize this callback and processed it as a normal request. This can occur if there are multiple Callback/CallbackPanel controls in the page, and this Callback/CallbackPanel control was initially dynamically loaded but wasn't loaded for this callback.
This can also occur if you have called Response.Redirect on the server side. Callback/CalbackPanel provides a Redirect method for such scenario. Please use the Callback/CallbackPanel's Redirect method in this case.(set ClientSideOnError to handle this error).
You can turn off this message by setting EO.Web.Runtime.DebugLevel to 0 (Not recommended for debug build).
Setting DebugLevel to 0 prevents the message from being shown but leaves the calendar control unresponsive.
.aspx:
Quote:<%@ Page Language="C#" Trace="true" AutoEventWireup="true" CodeFile="EOCalendarTest.aspx.cs" Inherits="CalendarTest" %>
<%@ Register assembly="EO.Web" namespace="EO.Web" tagprefix="eo" %>
<!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">
<title></title>
<style type="text/css">
.otherMonth {
color: #999999;
}
.nonWorkingDay {
color: #FF0000;
}
.workingDay
{
font-weight: bold;
color: #009933;
}color: #999999;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<eo:DatePicker ID="DatePicker1" runat="server" ControlSkinID="None"
DayCellHeight="16" DayCellWidth="19" DayHeaderFormat="FirstLetter"
DisabledDates="" OtherMonthDayVisible="True" SelectedDates=""
TitleLeftArrowImageUrl="DefaultSubMenuIconRTL"
TitleRightArrowImageUrl="DefaultSubMenuIcon" VisibleDate="2008-10-01"
PickerFormat="dd/MM/yyyy" ondayrender="DatePicker1_DayRender">
<TodayStyle CssText="font-family: tahoma; font-size: 12px; border-right: #bb5503 1px solid; border-top: #bb5503 1px solid; border-left: #bb5503 1px solid; border-bottom: #bb5503 1px solid" />
<SelectedDayStyle CssText="font-family: tahoma; font-size: 12px; background-color: #fbe694; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
<DisabledDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
<PickerStyle CssText="font-family:Courier New; padding-left:5px; padding-right: 5px;" />
<CalendarStyle CssText="background-color: white; border-right: #7f9db9 1px solid; padding-right: 4px; border-top: #7f9db9 1px solid; padding-left: 4px; font-size: 9px; padding-bottom: 4px; border-left: #7f9db9 1px solid; padding-top: 4px; border-bottom: #7f9db9 1px solid; font-family: tahoma" />
<TitleArrowStyle CssText="cursor:hand" />
<DayHoverStyle CssText="font-family: tahoma; font-size: 12px; border-right: #fbe694 1px solid; border-top: #fbe694 1px solid; border-left: #fbe694 1px solid; border-bottom: #fbe694 1px solid" />
<MonthStyle CssText="font-family: tahoma; font-size: 12px; margin-left: 14px; cursor: hand; margin-right: 14px" />
<TitleStyle CssText="background-color:#9ebef5;font-family:Tahoma;font-size:12px;padding-bottom:2px;padding-left:6px;padding-right:6px;padding-top:2px;" />
<OtherMonthDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
<DayHeaderStyle CssText="font-family: tahoma; font-size: 12px; border-bottom: #aca899 1px solid" />
<DayStyle CssText="font-family: tahoma; font-size: 12px; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" />
</eo:DatePicker>
</div>
</form>
</body>
</html>
.cs:
Quote:using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class CalendarTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//EO.Web.Runtime.DebugLevel = 0;
}
public void DatePicker1_DayRender(object sender, EO.Web.DayRenderEventArgs e)
{
if (e.Day.IsOtherMonth)
{
e.Writer.Write("<span class='otherMonth'>{0}</span>", e.Day.DayNumberText);
}
else if (e.Day.IsWeekend || e.Day.DayNumberText.EndsWith("3"))
{
e.Day.IsSelectable = false;
e.Writer.Write("<span class='nonWorkingDay'>{0}</span>", e.Day.DayNumberText);
}
else
{
e.Writer.Write("<span class='workingDay'>{0}</span>", e.Day.DayNumberText);
}
}
}
am i doing something wrong?