2006-12-07 Igor Zelmanovich <igorz@mainsoft.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / Calendar.cs
old mode 100755 (executable)
new mode 100644 (file)
index 8900671..ef9010d
@@ -2,15 +2,11 @@
 // System.Web.UI.WebControls.Calendar.cs
 //
 // Authors:
-//   Gaurav Vaish (gvaish@iitk.ac.in)
-//   Gonzalo Paniagua Javier (gonzalo@ximian.com)
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
+//    Jordi Mas i Hernandez (jordi@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
 //
-// (c) Copyright 2002 Ximian, Inc. (http://www.ximian.com)
-// (C) Gaurav Vaish (2002)
-// (C) 2003 Andreas Nahr
-//\r
-
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // distribute, sublicense, and/or sell copies of the Software, and to
 // permit persons to whom the Software is furnished to do so, subject to
 // the following conditions:
-// 
+//
 // The above copyright notice and this permission notice shall be
 // included in all copies or substantial portions of the Software.
-// 
+//
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-\r
-using System;\r
-using System.IO;\r
-using System.Collections;\r
-using System.Globalization;\r
-using System.Text;\r
-using System.Web;\r
-using System.Web.UI;\r
-using System.Drawing;\r
+//
+
+using System.Globalization;
+using System.Collections;
 using System.ComponentModel;
-using System.ComponentModel.Design;\r
-\r
-namespace System.Web.UI.WebControls\r
-{\r
-#if NET_2_0\r
-//     [ControlValuePropertyAttribute ("SelectedDate", DateTime.MinValue)]\r
-#endif\r
-       [DefaultEvent("SelectionChanged")]\r
-       [DefaultProperty("SelectedDate")]\r
-       [Designer("System.Web.UI.Design.WebControls.CalendarDesigner, " + Consts.AssemblySystem_Design, typeof (IDesigner))]\r
+using System.Drawing;
+using System.Security.Permissions;
+using System.Threading;
+
+namespace System.Web.UI.WebControls {
+       // CAS
+       [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+       [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+       // attributes
        [DataBindingHandler("System.Web.UI.Design.WebControls.CalendarDataBindingHandler, " + Consts.AssemblySystem_Design)]
-       public class Calendar : WebControl, IPostBackEventHandler\r
-       {\r
-               //\r
-               private TableItemStyle          dayHeaderStyle;\r
-               private TableItemStyle          dayStyle;\r
-               private TableItemStyle          nextPrevStyle;\r
-               private TableItemStyle          otherMonthDayStyle;\r
-               private SelectedDatesCollection selectedDates;\r
-               private ArrayList               selectedDatesList;\r
-               private TableItemStyle          selectedDayStyle;\r
-               private TableItemStyle          selectorStyle;\r
-               private TableItemStyle          titleStyle;\r
-               private TableItemStyle          todayDayStyle;\r
-               private TableItemStyle          weekendDayStyle;\r
-\r
-               private static readonly object DayRenderEvent           = new object();\r
-               private static readonly object SelectionChangedEvent    = new object();\r
-               private static readonly object VisibleMonthChangedEvent = new object();\r
-\r
-               private Color defaultTextColor;\r
-               private System.Globalization.Calendar globCal;\r
-               private DateTimeFormatInfo infoCal = DateTimeFormatInfo.CurrentInfo;
-
-               private static readonly DateTime begin_date = new DateTime (2000,01,01,0,0,0,0);
-                               
-\r
-               private static int MASK_WEEKEND  = (0x01 << 0);\r
-               private static int MASK_OMONTH   = (0x01 << 1);\r
-               private static int MASK_TODAY    = (0x01 << 2);\r
-               private static int MASK_SELECTED = (0x01 << 3);\r
-               private static int MASK_DAY      = (0x01 << 4);\r
-               private static int MASK_UNIQUE = MASK_WEEKEND | MASK_OMONTH | MASK_TODAY | MASK_SELECTED;\r
-\r
-               public Calendar(): base()\r
-               {\r
-               }\r
-
-\r
-#if !NET_2_0\r
-               [Bindable (true)]\r
+       [DefaultEvent("SelectionChanged")]
+       [DefaultProperty("SelectedDate")]
+       [Designer("System.Web.UI.Design.WebControls.CalendarDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+#if NET_2_0
+       [ControlValueProperty ("SelectedDate", "1/1/0001 12:00:00 AM")]
+       [SupportsEventValidation]
+#endif         
+       public class Calendar : WebControl, IPostBackEventHandler {
+
+               private TableItemStyle dayHeaderStyle;
+               private TableItemStyle dayStyle;
+               private TableItemStyle nextPrevStyle;
+               private TableItemStyle otherMonthDayStyle;
+               private TableItemStyle selectedDayStyle;
+               private TableItemStyle titleStyle;
+               private TableItemStyle todayDayStyle;
+               private TableItemStyle selectorStyle;
+               private TableItemStyle weekendDayStyle;
+               private DateTimeFormatInfo dateInfo;
+               private SelectedDatesCollection selectedDatesCollection;
+               private ArrayList dateList;
+               private static DateTime dateZenith  = new DateTime (2000, 1,1);
+               private const int daysInAWeek = 7;
+               private static readonly object DayRenderEvent = new object ();
+               private static readonly object SelectionChangedEvent = new object ();
+               private static readonly object VisibleMonthChangedEvent = new object ();
+
+               public Calendar ()
+               {
+                       dateInfo = Thread.CurrentThread.CurrentUICulture.DateTimeFormat;
+               }
+
+#if NET_2_0
+               [Localizable (true)]
+               [DefaultValue ("")]
+               [WebSysDescription ("")]
+               [WebCategoryAttribute ("Appearance")]
+               public virtual string Caption 
+               {
+                       get {
+                               return ViewState.GetString ("Caption", "");
+                       }
+                       set {
+                               ViewState["Caption"] = value;
+                       }
+               }
+
+               [DefaultValue (TableCaptionAlign.NotSet)]
+               [WebSysDescription ("")]
+               [WebCategoryAttribute ("Accessibility")]
+               public virtual TableCaptionAlign CaptionAlign 
+               {
+                       get {
+                               return (TableCaptionAlign)ViewState.GetInt ("CaptionAlign", (int)TableCaptionAlign.NotSet);
+                       }
+                       set {
+                               ViewState ["CaptionAlign"] = value;
+                       }
+               }
 #endif
-               [DefaultValue (2), WebCategory ("Layout")]
-               [WebSysDescription ("The border left within the calendar days.")]\r
-               public int CellPadding\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["CellPadding"];\r
-                               if(o!=null)\r
-                                       return (int)o;\r
-                               return 2;\r
-                       }\r
-                       set\r
-                       {
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue(2)]
+               [WebSysDescription ("")]
+               [WebCategory ("Layout")]
+               public int CellPadding {
+                       get {
+                               return ViewState.GetInt ("CellPadding", 2);
+                       }
+
+                       set {
                                if (value < -1)
-                                       throw new ArgumentOutOfRangeException ("value", "CellPadding value has to be -1 for 'not set' or > -1.");\r
-                               ViewState["CellPadding"] = value;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#endif\r
-               [DefaultValue (0), WebCategory ("Layout")]
-               [WebSysDescription ("The border left between calendar days.")]\r
-               public int CellSpacing\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["CellSpacing"];\r
-                               if(o!=null)\r
-                                       return (int)o;\r
-                               return 0;\r
-                       }\r
-                       set\r
-                       {\r
+                                       throw new ArgumentOutOfRangeException ("The specified cell padding is less than -1.");
+
+                               ViewState ["CellPadding"] = value;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue(0)]
+               [WebSysDescription ("")]
+               [WebCategory ("Layout")]
+               public int CellSpacing {
+                       get {
+                               return ViewState.GetInt ("CellSpacing", 0);
+                       }
+
+                       set {
                                if (value < -1)
-                                       throw new ArgumentOutOfRangeException ("value", "CellSpacing value has to be -1 for 'not set' or > -1.");\r
-                               ViewState["CellSpacing"] = value;\r
-                       }\r
-               }\r
-
-               [NotifyParentProperty (true), WebCategory ("Style")]
-               [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
-               [PersistenceMode (PersistenceMode.InnerProperty)]
-               [WebSysDescription ("The style applied to the day header.")]\r
-               public TableItemStyle DayHeaderStyle\r
-               {\r
-                       get\r
-                       {\r
-                               if(dayHeaderStyle==null)\r
-                                       dayHeaderStyle = new TableItemStyle();\r
-                               if(IsTrackingViewState)\r
-                                       dayHeaderStyle.TrackViewState();\r
-                               return dayHeaderStyle;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#endif\r
-               [DefaultValue (typeof (DayNameFormat), "Short"), WebCategory ("Appearance")]
-               [WebSysDescription ("The format for the day name display.")]\r
-               public DayNameFormat DayNameFormat\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["DayNameFormat"];\r
-                               if(o!=null)\r
-                                       return (DayNameFormat)o;\r
-                               return DayNameFormat.Short;\r
-                       }\r
-                       set\r
-                       {\r
-                               if(!System.Enum.IsDefined(typeof(DayNameFormat),value))\r
-                                       throw new ArgumentOutOfRangeException ("value", "Only valid enumeration members are allowed");\r
-                               ViewState["DayNameFormat"] = value;\r
-                       }\r
-               }\r
-
-               [DefaultValue (null)]
-               [NotifyParentProperty (true), WebCategory ("Style")]
-               [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
-               [PersistenceMode (PersistenceMode.InnerProperty)]
-               [WebSysDescription ("The style applied to the day entry.")]\r
-               public TableItemStyle DayStyle\r
-               {\r
-                       get\r
-                       {\r
-                               if(dayStyle==null)\r
-                                       dayStyle = new TableItemStyle();\r
-                               if(IsTrackingViewState)\r
-                                       dayStyle.TrackViewState();\r
-                               return dayStyle;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#endif\r
-               [DefaultValue (typeof (FirstDayOfWeek), "Default"), WebCategory ("Appearance")]
-               [WebSysDescription ("The day that a week begins with.")]\r
-               public FirstDayOfWeek FirstDayOfWeek\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["FirstDayOfWeek"];\r
-                               if(o!=null)\r
-                                       return (FirstDayOfWeek)o;\r
-                               return FirstDayOfWeek.Default;\r
-                       }\r
-                       set\r
-                       {\r
-                               if(!System.Enum.IsDefined(typeof(FirstDayOfWeek), value))\r
-                                       throw new ArgumentOutOfRangeException ("value", "Only valid enumeration members are allowed");\r
-                               ViewState["FirstDayOfWeek"] = value;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#else\r
-               [Localizable (true)]\r
-#endif\r
-               [DefaultValue (">"), WebCategory ("Appearance")]
-               [WebSysDescription ("The text for selecting the next month.")]\r
-               public string NextMonthText\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["NextMonthText"];\r
-                               if(o!=null)\r
-                                       return (string)o;\r
-                               return "&gt;";\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["NextMonthText"] = value;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#endif\r
-               [DefaultValue (typeof (NextPrevFormat), "CustomText"), WebCategory ("Appearance")]
-               [WebSysDescription ("The format for the month navigation.")]\r
-               public NextPrevFormat NextPrevFormat\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["NextPrevFormat"];\r
-                               if(o!=null)\r
-                                       return (NextPrevFormat)o;\r
-                               return NextPrevFormat.CustomText;\r
-                       }\r
-                       set\r
-                       {\r
-                               if(!System.Enum.IsDefined(typeof(NextPrevFormat), value))\r
-                                       throw new ArgumentOutOfRangeException ("value", "Only valid enumeration members are allowed");\r
-                               ViewState["NextPrevFormat"] = value;\r
-                       }\r
-               }\r
-
-               [NotifyParentProperty (true), WebCategory ("Style")]
-               [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
-               [PersistenceMode (PersistenceMode.InnerProperty)]
-               [WebSysDescription ("The style applied to the month navigation.")]\r
-               public TableItemStyle NextPrevStyle\r
-               {\r
-                       get\r
-                       {\r
-                               if(nextPrevStyle == null)\r
-                                       nextPrevStyle = new TableItemStyle();\r
-                               if(IsTrackingViewState)\r
-                                       nextPrevStyle.TrackViewState();\r
-                               return nextPrevStyle;\r
-                       }\r
-               }\r
-
-               [DefaultValue (null)]
-               [NotifyParentProperty (true), WebCategory ("Style")]
-               [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
-               [PersistenceMode (PersistenceMode.InnerProperty)]
-               [WebSysDescription ("The style applied to day entries belonging to another month.")]\r
-               public TableItemStyle OtherMonthDayStyle\r
-               {\r
-                       get\r
-                       {\r
-                               if(otherMonthDayStyle == null)\r
-                                       otherMonthDayStyle = new TableItemStyle();\r
-                               if(IsTrackingViewState)\r
-                                       otherMonthDayStyle.TrackViewState();\r
-                               return otherMonthDayStyle;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#else\r
-               [Localizable (true)]\r
-#endif\r
-               [DefaultValue ("<"), WebCategory ("Appearance")]
-               [WebSysDescription ("The text for selecting the previous month.")]\r
-               public string PrevMonthText\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["PrevMonthText"];\r
-                               if(o!=null)\r
-                                       return (string)o;\r
-                               return "&lt;";\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["PrevMonthText"] = value;\r
-                       }\r
-               }\r
-
-               [DefaultValue (null), Bindable (true)]
-               [WebSysDescription ("The currently selected date.")]\r
-               public DateTime SelectedDate\r
-               {\r
-                       get\r
-                       {\r
-                               if(SelectedDates.Count > 0)\r
-                               {\r
-                                       return SelectedDates[0];\r
-                               }\r
-                               return DateTime.MinValue;\r
-                       }\r
-                       set\r
-                       {\r
-                               if(value == DateTime.MinValue)\r
-                               {\r
-                                       SelectedDates.Clear();\r
-                               } else\r
-                               {\r
-                                       SelectedDates.SelectRange(value, value);\r
-                               }\r
-                       }\r
-               }\r
-
-               [Browsable (false), DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-               [WebSysDescription ("All currently selected dates.")]\r
-               public SelectedDatesCollection SelectedDates\r
-               {\r
-                       get\r
-                       {\r
-                               if(selectedDates==null)\r
-                               {\r
-                                       if(selectedDatesList == null)\r
-                                               selectedDatesList = new ArrayList();\r
-                                       selectedDates = new SelectedDatesCollection(selectedDatesList);\r
-                               }\r
-                               return selectedDates;\r
-                       }\r
-               }\r
-
-               [DefaultValue (null)]
-               [NotifyParentProperty (true), WebCategory ("Style")]
-               [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
-               [PersistenceMode (PersistenceMode.InnerProperty)]
-               [WebSysDescription ("The style applied to the selected day.")]\r
-               public TableItemStyle SelectedDayStyle\r
-               {\r
-                       get\r
-                       {\r
-                               if(selectedDayStyle==null)\r
-                                       selectedDayStyle = new TableItemStyle();\r
-                               if(IsTrackingViewState)\r
-                                       selectedDayStyle.TrackViewState();\r
-                               return selectedDayStyle;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#endif\r
-               [DefaultValue (typeof (CalendarSelectionMode), "Day"), WebCategory ("Behavior")]
-               [WebSysDescription ("The mode in which days or other entries are selected.")]\r
-               public CalendarSelectionMode SelectionMode\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["SelectionMode"];\r
-                               if(o!=null)\r
-                                       return (CalendarSelectionMode)o;\r
-                               return CalendarSelectionMode.Day;\r
-                       }\r
-                       set\r
-                       {\r
-                               if(!System.Enum.IsDefined(typeof(CalendarSelectionMode), value))\r
-                                       throw new ArgumentOutOfRangeException ("value", "Only valid enumeration members are allowed");\r
-                               ViewState["SelectionMode"] = value;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#else\r
-               [Localizable (true)]\r
-#endif\r
-               [DefaultValue (">>"), WebCategory ("Appearance")]
-               [WebSysDescription ("The text that is used for selection of months.")]\r
-               public string SelectMonthText\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["SelectMonthText"];\r
-                               if(o!=null)\r
-                                       return (string)o;\r
-                               return "&gt;&gt;";\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["SelectMonthText"] = value;\r
-                       }\r
-               }\r
-
-               [NotifyParentProperty (true), WebCategory ("Style")]
-               [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
-               [PersistenceMode (PersistenceMode.InnerProperty)]
-               [WebSysDescription ("The style applied to the selector.")]\r
-               public TableItemStyle SelectorStyle\r
-               {\r
-                       get\r
-                       {\r
-                               if(selectorStyle==null)\r
-                                       selectorStyle = new TableItemStyle();\r
-                               return selectorStyle;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#else\r
-               [Localizable (true)]\r
-#endif\r
-               [DefaultValue (">"), WebCategory ("Appearance")]
-               [WebSysDescription ("The text that is used for selection of weeks.")]\r
-               public string SelectWeekText\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["SelectWeekText"];\r
-                               if(o!=null)\r
-                                       return (string)o;\r
-                               return "&gt;";\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["SelectWeekText"] = value;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#endif\r
-               [DefaultValue (true), WebCategory ("Appearance")]
-               [WebSysDescription ("Determines if the header for days is shown.")]\r
-               public bool ShowDayHeader\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["ShowDayHeader"];\r
-                               if(o!=null)\r
-                                       return (bool)o;\r
-                               return true;\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["ShowDayHeader"] = value;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#endif\r
-               [DefaultValue (false), WebCategory ("Appearance")]
-               [WebSysDescription ("Determines if gridlines are shown.")]\r
-               public bool ShowGridLines\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["ShowGridLines"];\r
-                               if(o!=null)\r
-                                       return (bool)o;\r
-                               return false;\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["ShowGridLines"] = value;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#endif\r
-               [DefaultValue (true), WebCategory ("Appearance")]
-               [WebSysDescription ("Determines if month navigation is shown.")]\r
-               public bool ShowNextPrevMonth\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["ShowNextPrevMonth"];\r
-                               if(o!=null)\r
-                                       return (bool)o;\r
-                               return true;\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["ShowNextPrevMonth"] = value;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#endif\r
-               [DefaultValue (true), WebCategory ("Appearance")]
-               [WebSysDescription ("Determines if the title is shown.")]\r
-               public bool ShowTitle\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["ShowTitle"];\r
-                               if(o!=null)\r
-                                       return (bool)o;\r
-                               return true;\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["ShowTitle"] = value;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#endif\r
-               [DefaultValue (typeof (TitleFormat), "MonthYear"), WebCategory ("Appearance")]
-               [WebSysDescription ("The format in which the title is rendered.")]\r
-               public TitleFormat TitleFormat\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["TitleFormat"];\r
-                               if(o!=null)\r
-                                       return (TitleFormat)o;\r
-                               return TitleFormat.MonthYear;\r
-                       }\r
-                       set\r
-                       {\r
-                               if(!System.Enum.IsDefined(typeof(TitleFormat), value))\r
-                                       throw new ArgumentOutOfRangeException ("value", "Only valid enumeration members are allowed");\r
-                               ViewState["TitleFormat"] = value;\r
-                       }\r
-               }\r
-
-               [NotifyParentProperty (true), WebCategory ("Style")]
-               [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
-               [PersistenceMode (PersistenceMode.InnerProperty)]
-               [WebSysDescription ("The style applied to the title.")]\r
-               public TableItemStyle TitleStyle\r
-               {\r
-                       get\r
-                       {\r
-                               if(titleStyle==null)\r
-                                       titleStyle = new TableItemStyle();\r
-                               if(IsTrackingViewState)\r
-                                       titleStyle.TrackViewState();\r
-                               return titleStyle;\r
-                       }\r
-               }\r
-
-               [DefaultValue (null)]
-               [NotifyParentProperty (true), WebCategory ("Style")]
-               [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
-               [PersistenceMode (PersistenceMode.InnerProperty)]
-               [WebSysDescription ("The style applied to the today's date display.")]\r
-               public TableItemStyle TodayDayStyle\r
-               {\r
-                       get\r
-                       {\r
-                               if(todayDayStyle==null)\r
-                                       todayDayStyle = new TableItemStyle();\r
-                               if(IsTrackingViewState)\r
-                                       todayDayStyle.TrackViewState();\r
-                               return todayDayStyle;\r
-                       }\r
-               }\r
-
-#if !NET_2_0\r
-               [Bindable (true)]\r
-#endif\r
-               [Browsable (false)]
-               [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-               [WebSysDescription ("The current date.")]\r
-               public DateTime TodaysDate\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["TodaysDate"];\r
-                               if(o!=null)\r
-                                       return (DateTime)o;\r
-                               return DateTime.Today;\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["TodaysDate"] = value.Date;\r
-                       }\r
-               }\r
-
-               [DefaultValue (null), Bindable (true)]
-               [WebSysDescription ("The month that is displayed.")]\r
-               public DateTime VisibleDate\r
-               {\r
-                       get\r
-                       {\r
-                               object o = ViewState["VisibleDate"];\r
-                               if(o!=null)\r
-                                       return (DateTime)o;\r
-                               return DateTime.MinValue;\r
-                       }\r
-                       set\r
-                       {\r
-                               ViewState["VisibleDate"] = value.Date;\r
-                       }\r
-               }\r
-
-               [NotifyParentProperty (true), WebCategory ("Style")]
-               [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
-               [PersistenceMode (PersistenceMode.InnerProperty)]
-               [WebSysDescription ("The style applied to weekend days.")]\r
-               public TableItemStyle WeekendDayStyle\r
-               {\r
-                       get\r
-                       {\r
-                               if(weekendDayStyle == null)\r
-                                       weekendDayStyle = new TableItemStyle();\r
-                               if(IsTrackingViewState)\r
-                               {\r
-                                       weekendDayStyle.TrackViewState();\r
-                               }\r
-                               return weekendDayStyle;\r
-                       }\r
-               }\r
+                                       throw new ArgumentOutOfRangeException ("The specified cell spacing is less than -1");
 
-               [WebCategory ("Action")]
-               [WebSysDescription ("Raised when a day entry is rendered.")]\r
-               public event DayRenderEventHandler DayRender\r
-               {\r
-                       add\r
-                       {\r
-                               Events.AddHandler(DayRenderEvent, value);\r
-                       }\r
-                       remove\r
-                       {\r
-                               Events.RemoveHandler(DayRenderEvent, value);\r
-                       }\r
-               }\r
+                               ViewState ["CellSpacing"] = value;
+                       }
+               }
 
-               [WebCategory ("Action")]
-               [WebSysDescription ("Raised when another entry is selected.")]\r
-               public event EventHandler SelectionChanged\r
-               {\r
-                       add\r
-                       {\r
-                               Events.AddHandler(SelectionChangedEvent, value);\r
-                       }\r
-                       remove\r
-                       {\r
-                               Events.RemoveHandler(SelectionChangedEvent, value);\r
-                       }\r
-               }\r
+               [PersistenceMode(PersistenceMode.InnerProperty)]
+               [NotifyParentProperty(true)]
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+               [WebSysDescription ("")]
+               [WebCategory ("Style")]
+               public TableItemStyle DayHeaderStyle {
+                       get {
+                               if (dayHeaderStyle == null) {
+                                       dayHeaderStyle = new TableItemStyle ();
+                                       if (IsTrackingViewState)
+                                               dayHeaderStyle.TrackViewState ();
+                               }
 
-               [WebCategory ("Action")]
-               [WebSysDescription ("Raised when a the currently visible month has changed.")]\r
-               public event MonthChangedEventHandler VisibleMonthChanged\r
-               {\r
-                       add\r
-                       {\r
-                               Events.AddHandler(VisibleMonthChangedEvent, value);\r
-                       }\r
-                       remove\r
-                       {\r
-                               Events.RemoveHandler(VisibleMonthChangedEvent, value);\r
-                       }\r
-               }\r
-               \r
-#if NET_2_0\r
-               [MonoTODO ("Do something with this")]\r
-               [DefaultValueAttribute ("")]\r
-               [WebCategoryAttribute ("Appearance")]\r
-               public string CalendarEntryText {\r
-                       get {\r
-                               object o = ViewState ["CalendarEntryText"];\r
-                               if (o != null) return (string) o;\r
-                               return "";\r
-                       }\r
-                       set {\r
-                               ViewState ["CalendarEntryText"] = value;\r
-                       }\r
-               }\r
-\r
-               [LocalizableAttribute (true)]\r
-               [DefaultValueAttribute ("")]\r
-               [WebCategoryAttribute ("Accessibility")]\r
-               public string Caption {\r
-                       get {\r
-                               object o = ViewState ["Caption"];\r
-                               if (o != null) return (string) o;\r
-                               return "";\r
-                       }\r
-                       set {\r
-                               ViewState ["Caption"] = value;\r
-                       }\r
-               }\r
-\r
-       [WebCategoryAttribute ("Accessibility")]\r
-           [DefaultValueAttribute (TableCaptionAlign.NotSet)]\r
-               public TableCaptionAlign CaptionAlign {\r
-                       get {\r
-                               object o = ViewState ["CaptionAlign"];\r
-                               if (o != null) return (TableCaptionAlign) o;\r
-                               return TableCaptionAlign.NotSet;\r
-                       }\r
-                       set {\r
-                               ViewState ["CaptionAlign"] = value;\r
-                       }\r
-               }\r
-\r
-               [DefaultValueAttribute (false)]\r
-               [WebCategoryAttribute ("Accessibility")]\r
-               public bool UseAccessibleHeader {\r
-                       get {\r
-                               object o = ViewState ["UseAccessibleHeader"];\r
-                               if (o != null) return (bool) o;\r
-                               return false;\r
-                       }\r
-                       set {\r
-                               ViewState ["UseAccessibleHeader"] = value;\r
-                       }\r
-               }\r
-#endif\r
-\r
-               protected virtual void OnDayRender(TableCell cell, CalendarDay day)\r
-               {\r
-                       if(Events!=null)\r
-                       {\r
-                               DayRenderEventHandler dreh = (DayRenderEventHandler)(Events[DayRenderEvent]);\r
-                               if(dreh!=null)\r
-                                       dreh(this, new DayRenderEventArgs(cell, day));\r
-                       }\r
-               }\r
-\r
-               protected virtual void OnSelectionChanged()\r
-               {\r
-                       if(Events!=null)\r
-                       {\r
-                               EventHandler eh = (EventHandler)(Events[SelectionChangedEvent]);\r
-                               if(eh!=null)\r
-                                       eh(this, new EventArgs());\r
-                       }\r
-               }\r
-\r
-               protected virtual void OnVisibleMonthChanged(DateTime newDate, DateTime prevDate)\r
-               {\r
-                       if(Events!=null)\r
-                       {\r
-                               MonthChangedEventHandler mceh = (MonthChangedEventHandler)(Events[VisibleMonthChangedEvent]);\r
-                               if(mceh!=null)\r
-                                       mceh(this, new MonthChangedEventArgs(newDate, prevDate));\r
-                       }\r
-               }\r
-\r
-               /// <remarks>\r
-               /// See test6.aspx in Tests directory for verification\r
-               /// </remarks>\r
-#if NET_2_0\r
-               void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)\r
-               {\r
-                       RaisePostBackEvent (eventArgument);\r
-               }\r
-               \r
-               protected virtual void RaisePostBackEvent (string eventArgument)\r
-#else\r
-               void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)\r
-#endif\r
-               {\r
-                       // initialize the calendar...TODO: find out why this isn't done in the constructor
-                       // if the culture is changed between rendering and postback this will be broken
-                       globCal = DateTimeFormatInfo.CurrentInfo.Calendar;\r
-
-                       // TODO: Find out what kind of exceptions to throw when we get bad data
-                       if (eventArgument.StartsWith ("V")) {
-                               TimeSpan mod = new TimeSpan (Int32.Parse (eventArgument.Substring (1)), 0, 0, 0);
-                               DateTime new_date = begin_date + mod;
-                               VisibleDate = new_date;
-                               OnVisibleMonthChanged (VisibleDate, new_date);
-                       } else if (eventArgument.StartsWith ("R")) {
-                               TimeSpan mod = new TimeSpan (Int32.Parse (eventArgument.Substring (1,
-                                                                                         eventArgument.Length - 3)), 0, 0, 0);
-                               DateTime range_begin = begin_date + mod;
-                               int sel_days = Int32.Parse (eventArgument.Substring (eventArgument.Length - 2));
-                               SelectRangeInternal (range_begin, range_begin.AddDays (sel_days - 1), GetEffectiveVisibleDate ());
-                       } else {
-                               TimeSpan mod = new TimeSpan (Int32.Parse (eventArgument), 0, 0, 0);
-                               DateTime day = begin_date + mod;
-                               SelectRangeInternal (day, day, GetEffectiveVisibleDate ());
-                       }\r
-               }\r
-\r
-               protected override void OnPreRender (EventArgs e)
+                               return dayHeaderStyle;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue(DayNameFormat.Short)]
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public DayNameFormat DayNameFormat {
+                       get {
+                               return (DayNameFormat) ViewState.GetInt ("DayNameFormat", (int) DayNameFormat.Short);
+                       }
+
+                       set {
+                               if (value != DayNameFormat.FirstLetter && value != DayNameFormat.FirstTwoLetters &&
+                                       value != DayNameFormat.Full && value != DayNameFormat.Short) {
+                                       throw new ArgumentOutOfRangeException ("The specified day name format is not one of the DayNameFormat values.");
+                               }
+
+                               ViewState ["DayNameFormat"] = value;
+                       }
+               }
+
+               [DefaultValue(null)]
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+               [NotifyParentProperty(true)]
+               [PersistenceMode(PersistenceMode.InnerProperty)]
+               [WebSysDescription ("")]
+               [WebCategory ("Style")]
+               public TableItemStyle DayStyle {
+                       get {
+                               if (dayStyle == null) {
+                                       dayStyle = new TableItemStyle ();
+                                       if (IsTrackingViewState)
+                                               dayStyle.TrackViewState ();
+                               }
+
+                               return dayStyle;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue(FirstDayOfWeek.Default)]
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public FirstDayOfWeek FirstDayOfWeek {
+                       get {
+                               return (FirstDayOfWeek) ViewState.GetInt ("FirstDayOfWeek", (int) FirstDayOfWeek.Default);
+                       }
+
+                       set {
+                               if (value < FirstDayOfWeek.Sunday || value > FirstDayOfWeek.Default) {
+                                       throw new ArgumentOutOfRangeException ("The specified day name format is not one of the DayNameFormat values.");
+                               }
+
+                               ViewState ["FirstDayOfWeek"] = value;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue("&gt;")]
+#if NET_2_0
+               [Localizable (true)]
+#endif
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public string NextMonthText {
+                       get {
+                               return ViewState.GetString ("NextMonthText", "&gt;");
+                       }
+
+                       set {
+                               ViewState ["NextMonthText"] = value;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue(NextPrevFormat.CustomText)]
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public NextPrevFormat NextPrevFormat {
+                       get {
+                               return (NextPrevFormat) ViewState.GetInt ("NextPrevFormat", (int) NextPrevFormat.CustomText);
+                       }
+
+                       set {
+                               if (value != NextPrevFormat.CustomText && value != NextPrevFormat.ShortMonth && value != NextPrevFormat.FullMonth) {
+                                       throw new ArgumentOutOfRangeException ("The specified day name format is not one of the DayNameFormat values.");
+                               }
+
+                               ViewState ["NextPrevFormat"] = value;
+                       }
+               }
+
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+               [NotifyParentProperty(true)]
+               [PersistenceMode(PersistenceMode.InnerProperty)]
+               [WebSysDescription ("")]
+               [WebCategory ("Style")]
+               public TableItemStyle NextPrevStyle {
+                       get {
+                               if (nextPrevStyle == null) {
+                                       nextPrevStyle = new TableItemStyle ();
+                                       if (IsTrackingViewState)
+                                               nextPrevStyle.TrackViewState ();
+                               }
+
+                               return nextPrevStyle;
+                       }
+               }
+
+               [DefaultValue(null)]
+               [NotifyParentProperty(true)]
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+               [PersistenceMode(PersistenceMode.InnerProperty)]
+               [WebSysDescription ("")]
+               [WebCategory ("Style")]
+               public TableItemStyle OtherMonthDayStyle {
+                       get {
+                               if (otherMonthDayStyle == null) {
+                                       otherMonthDayStyle = new TableItemStyle ();
+                                       if (IsTrackingViewState)
+                                               otherMonthDayStyle.TrackViewState ();
+                               }
+
+                               return otherMonthDayStyle;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue("&lt;")]
+#if NET_2_0
+               [Localizable (true)]
+#endif
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public string PrevMonthText {
+                       get {
+                               return ViewState.GetString ("PrevMonthText", "&lt;");
+                       }
+
+                       set {
+                               ViewState ["PrevMonthText"] = value;
+                       }
+               }
+
+#if NET_2_0
+               [Bindable(true, BindingDirection.TwoWay)]
+#else
+               [Bindable(true)]
+#endif         
+               [DefaultValue("1/1/0001 12:00:00 AM")]
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public DateTime SelectedDate {
+                       get {
+                               if (SelectedDates.Count > 0)
+                                       return SelectedDates [0];
+
+                               return DateTime.MinValue;
+                       }
+
+                       set {
+                               SelectedDates.SelectRange (value, value);
+                       }
+               }
+
+               [Browsable(false)]
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public SelectedDatesCollection SelectedDates {
+                       get {
+                               if (dateList == null)
+                                       dateList = new ArrayList ();
+
+                               if (selectedDatesCollection == null)
+                                       selectedDatesCollection = new SelectedDatesCollection (dateList);
+
+                               return selectedDatesCollection;
+                       }
+               }
+
+               [DefaultValue(null)]
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+               [NotifyParentProperty(true)]
+               [PersistenceMode(PersistenceMode.InnerProperty)]
+               [WebSysDescription ("")]
+               [WebCategory ("Style")]
+               public TableItemStyle SelectedDayStyle {
+                       get {
+                               if (selectedDayStyle == null) {
+                                       selectedDayStyle = new TableItemStyle ();
+                                       if (IsTrackingViewState)
+                                               selectedDayStyle.TrackViewState ();
+                               }
+
+                               return selectedDayStyle;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue(CalendarSelectionMode.Day)]
+               [WebSysDescription ("")]
+               [WebCategory ("Behavior")]
+               public CalendarSelectionMode SelectionMode {
+                       get {
+                               return (CalendarSelectionMode) ViewState.GetInt ("SelectionMode", (int) CalendarSelectionMode.Day);
+                       }
+
+                       set {
+                               if (value != CalendarSelectionMode.Day  && value != CalendarSelectionMode.DayWeek &&
+                                       value != CalendarSelectionMode.DayWeekMonth  && value != CalendarSelectionMode.None) {
+                                       throw new ArgumentOutOfRangeException ("The specified selection mode is not one of the CalendarSelectionMode values.");
+                               }
+                               ViewState ["SelectionMode"] = value;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue("&gt;&gt;")]
+#if NET_2_0
+               [Localizable (true)]
+#endif
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public string SelectMonthText {
+                       get {
+                               return ViewState.GetString ("SelectMonthText", "&gt;&gt;");
+                       }
+
+                       set {
+                               ViewState ["SelectMonthText"] = value;
+                       }
+               }
+
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+               [NotifyParentProperty(true)]
+               [PersistenceMode(PersistenceMode.InnerProperty)]
+               [WebSysDescription ("")]
+               [WebCategory ("Style")]
+               public TableItemStyle SelectorStyle {
+                       get {
+                               if (selectorStyle == null) {
+                                        selectorStyle = new TableItemStyle ();
+                                       if (IsTrackingViewState)
+                                               selectorStyle.TrackViewState ();
+                               }
+
+                               return selectorStyle;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue("&gt;")]
+#if NET_2_0            
+               [Localizable (true)]
+#endif         
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public string SelectWeekText {
+                       get {
+                               return ViewState.GetString ("SelectWeekText", "&gt;");
+                       }
+
+                       set {
+                               ViewState ["SelectWeekText"] = value;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue(true)]
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public bool ShowDayHeader {
+                       get {
+                               return ViewState.GetBool ("ShowDayHeader", true);
+                       }
+
+                       set {
+                               ViewState ["ShowDayHeader"] = value;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue(false)]
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public bool ShowGridLines {
+                       get {
+                               return ViewState.GetBool ("ShowGridLines", false);
+                       }
+
+                       set {
+                               ViewState ["ShowGridLines"] = value;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue(true)]
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public bool ShowNextPrevMonth {
+                       get {
+                               return ViewState.GetBool ("ShowNextPrevMonth", true);
+                       }
+
+                       set {
+                               ViewState ["ShowNextPrevMonth"] = value;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue(true)]
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public bool ShowTitle {
+                       get {
+                               return ViewState.GetBool ("ShowTitle", true);
+                       }
+
+                       set {
+                               ViewState ["ShowTitle"] = value;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [DefaultValue(TitleFormat.MonthYear)]
+               [WebSysDescription ("")]
+               [WebCategory ("Appearance")]
+               public TitleFormat TitleFormat {
+                       get {
+                               return (TitleFormat) ViewState.GetInt ("TitleFormat", (int) TitleFormat.MonthYear);
+                       }
+
+                       set {
+                               if (value != TitleFormat.Month && value != TitleFormat.MonthYear) {
+                                       throw new ArgumentOutOfRangeException ("The specified title format is not one of the TitleFormat values.");
+                               }
+
+                               ViewState ["TitleFormat"] = value;
+                       }
+               }
+
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+               [NotifyParentProperty(true)]
+               [PersistenceMode(PersistenceMode.InnerProperty)]
+               [WebSysDescription ("")]
+               [WebCategory ("Style")]
+               public TableItemStyle TitleStyle {
+                       get {
+                               if (titleStyle == null) {
+                                       titleStyle = new TableItemStyle ();
+                                       if (IsTrackingViewState)
+                                               titleStyle.TrackViewState ();
+                               }
+
+                               return titleStyle;
+                       }
+               }
+
+               [DefaultValue(null)]
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+               [NotifyParentProperty(true)]
+               [PersistenceMode(PersistenceMode.InnerProperty)]
+               [WebSysDescription ("")]
+               [WebCategory ("Style")]
+               public TableItemStyle TodayDayStyle {
+                       get {
+                               if (todayDayStyle == null) {
+                                       todayDayStyle = new TableItemStyle ();
+                                       if (IsTrackingViewState)
+                                               todayDayStyle.TrackViewState ();
+                               }
+
+                               return todayDayStyle;
+                       }
+               }
+
+#if ONLY_1_1
+               [Bindable(true)]
+#endif         
+               [Browsable(false)]
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+               [WebSysDescription ("")]
+               [WebCategory ("Style")]
+               public DateTime TodaysDate {
+                       get {
+                               object obj = ViewState ["TodaysDate"];
+
+                               if (obj != null)
+                                       return (DateTime) obj;
+
+                               return DateTime.Today;
+                       }
+
+                       set {
+                               ViewState ["TodaysDate"] = value.Date;
+                       }
+               }
+
+#if NET_2_0
+               [DefaultValue (true)]
+               [WebSysDescription ("")]
+               [WebCategoryAttribute ("Accessibility")]
+               public virtual bool UseAccessibleHeader 
                {
-                       base.OnPreRender (e);
+                       get {
+                               return ViewState.GetBool ("UseAccessibleHeader", true);
+                       }
+                       set {
+                               ViewState ["UseAccessibleHeader"] = value;
+                       }
+               }
+#endif         
+
+               [Bindable(true)]
+               [DefaultValue("1/1/0001 12:00:00 AM")]
+               [WebSysDescription ("")]
+               [WebCategory ("Style")]
+               public DateTime VisibleDate {
+                       get {
+                               object obj = ViewState ["VisibleDate"];
+
+                               if (obj != null)
+                                       return (DateTime) obj;
+
+                               return DateTime.MinValue;
+                       }
+
+                       set {
+                               ViewState ["VisibleDate"] = value.Date;
+                       }
+               }
+
+               [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+               [NotifyParentProperty(true)]
+               [PersistenceMode(PersistenceMode.InnerProperty)]
+               [WebSysDescription ("")]
+               [WebCategory ("Style")]
+               public TableItemStyle WeekendDayStyle {
+                       get {
+                               if (weekendDayStyle == null) {
+                                       weekendDayStyle = new TableItemStyle ();
+                                       if (IsTrackingViewState)
+                                               weekendDayStyle.TrackViewState ();
+                               }
+
+                               return weekendDayStyle;
+                       }
+               }
+
+
+               // Private properties
+               private DateTime DisplayDate {
+                       get {
+                               DateTime dateTime = VisibleDate;
+                               if (dateTime == DateTime.MinValue) // If visibledate is still the default value
+                                       dateTime = TodaysDate;
+
+                               return dateTime;
+                       }
+               }
+
+               private DayOfWeek DisplayFirstDayOfWeek {
+                       get {
+                               if (FirstDayOfWeek != FirstDayOfWeek.Default)
+                                       return (DayOfWeek)  FirstDayOfWeek;
+
+                               return (DayOfWeek) dateInfo.FirstDayOfWeek;
+                       }
                }
 
-               protected override void Render(HtmlTextWriter writer)\r
-               {\r
-                       globCal = DateTimeFormatInfo.CurrentInfo.Calendar;\r
-                       DateTime visDate   = GetEffectiveVisibleDate();\r
-                       DateTime firstDate = GetFirstCalendarDay(visDate);\r
-\r
-                       bool isEnabled;\r
-                       bool isHtmlTextWriter;\r
-                       //FIXME: when Control.Site works, reactivate this\r
-                       //if (Page == null || Site == null) {\r
-                       //      isEnabled = false;\r
-                       //      isHtmlTextWriter = false;\r
-                       //} else {\r
-                               isEnabled = Enabled;\r
-                               isHtmlTextWriter = (writer.GetType() != typeof(HtmlTextWriter));\r
-                       //}\r
-                       defaultTextColor = ForeColor;\r
-                       if(defaultTextColor == Color.Empty)\r
-                               defaultTextColor = Color.Black;\r
-\r
-                       Table calTable = new Table ();\r
-                       calTable.ID = ID;\r
-                       calTable.CopyBaseAttributes(this);\r
-                       if(ControlStyleCreated)\r
-                               calTable.ApplyStyle(ControlStyle);\r
-                       calTable.Width = Width;\r
-                       calTable.Height = Height;\r
-                       calTable.CellSpacing = CellSpacing;\r
-                       calTable.CellPadding = CellPadding;\r
-\r
-                       if (ControlStyleCreated &&\r
-                           ControlStyle.IsSet (WebControls.Style.BORDERWIDTH) &&\r
-                           BorderWidth != Unit.Empty)\r
-                               calTable.BorderWidth = BorderWidth;\r
-                       else\r
-                               calTable.BorderWidth = Unit.Pixel(1);\r
-\r
-                       if (ShowGridLines)\r
-                               calTable.GridLines = GridLines.Both;\r
-                       else\r
-                               calTable.GridLines = GridLines.None;\r
-                               \r
-#if NET_2_0\r
-                       calTable.Caption = Caption;\r
-                       calTable.CaptionAlign = CaptionAlign;\r
-#endif\r
-\r
-                       calTable.RenderBeginTag (writer);\r
-\r
-                       if (ShowTitle)\r
-                               RenderTitle (writer, visDate, SelectionMode, isEnabled);\r
-\r
-                       if (ShowDayHeader)\r
-                               RenderHeader (writer, firstDate, SelectionMode, isEnabled, isHtmlTextWriter);\r
-\r
-                       RenderAllDays (writer, firstDate, visDate, SelectionMode, isEnabled, isHtmlTextWriter);\r
-\r
-                       calTable.RenderEndTag(writer);\r
-               }\r
-\r
-               protected override ControlCollection CreateControlCollection()\r
-               {\r
-                       return new EmptyControlCollection(this);\r
-               }\r
-\r
-               protected override void LoadViewState(object savedState)\r
-               {\r
-                       if (savedState!=null) {\r
-                               object[] states = (object[]) savedState;\r
-                               if(states[0] != null)\r
-                                       base.LoadViewState(states[0]);\r
-                               if(states[1] != null)\r
-                                       DayHeaderStyle.LoadViewState(states[1]);\r
-                               if(states[2] != null)\r
-                                       DayStyle.LoadViewState(states[2]);\r
-                               if(states[3] != null)\r
-                                       NextPrevStyle.LoadViewState(states[3]);\r
-                               if(states[4] != null)\r
-                                       OtherMonthDayStyle.LoadViewState(states[4]);\r
-                               if(states[5] != null)\r
-                                       SelectedDayStyle.LoadViewState(states[5]);\r
-                               if(states[6] != null)\r
-                                       SelectorStyle.LoadViewState(states[6]);\r
-                               if(states[7] != null)\r
-                                       TitleStyle.LoadViewState(states[7]);\r
-                               if(states[8] != null)\r
-                                       TodayDayStyle.LoadViewState(states[8]);\r
-                               if(states[9] != null)\r
-                                       WeekendDayStyle.LoadViewState(states[9]);\r
-\r
-                               ArrayList dateList = ViewState ["_CalendarSelectedDates"] as ArrayList;\r
-                               if (dateList != null)\r
-                                       selectedDates = new SelectedDatesCollection (dateList);\r
-                       }\r
-               }\r
-\r
-               protected override object SaveViewState()\r
+               protected override ControlCollection CreateControlCollection ()
                {
-                       if (SelectedDates.Count > 0)\r
-                               ViewState["_CalendarSelectedDates"] = selectedDates.GetDateList ();
-                       \r
-                       object[] states = new object [10];\r
-                       states[0] = base.SaveViewState();\r
-                       states[1] = (dayHeaderStyle == null ? null : dayHeaderStyle.SaveViewState());\r
-                       states[2] = (dayStyle == null ? null : dayStyle.SaveViewState());\r
-                       states[3] = (nextPrevStyle == null ? null : nextPrevStyle.SaveViewState());\r
-                       states[4] = (otherMonthDayStyle == null ? null : otherMonthDayStyle.SaveViewState());\r
-                       states[5] = (selectedDayStyle == null ? null : selectedDayStyle.SaveViewState());\r
-                       states[6] = (selectorStyle == null ? null : selectorStyle.SaveViewState());\r
-                       states[7] = (titleStyle == null ? null : titleStyle.SaveViewState());\r
-                       states[8] = (todayDayStyle == null ? null : todayDayStyle.SaveViewState());\r
-                       states[9] = (weekendDayStyle == null ? null : weekendDayStyle.SaveViewState());\r
-                       for(int i=0; i < states.Length; i++)\r
-                       {\r
-                               if(states[i]!=null)\r
-                                       return states;\r
-                       }\r
-                       return null;\r
-               }\r
-\r
-               protected override void TrackViewState()\r
-               {\r
-                       base.TrackViewState();\r
-                       if(titleStyle!=null)\r
-                       {\r
-                               titleStyle.TrackViewState();\r
-                       }\r
-                       if(nextPrevStyle!=null)\r
-                       {\r
-                               nextPrevStyle.TrackViewState();\r
-                       }\r
-                       if(dayStyle!=null)\r
-                       {\r
-                               dayStyle.TrackViewState();\r
-                       }\r
-                       if(dayHeaderStyle!=null)\r
-                       {\r
-                               dayHeaderStyle.TrackViewState();\r
-                       }\r
-                       if(todayDayStyle!=null)\r
-                       {\r
-                               todayDayStyle.TrackViewState();\r
-                       }\r
-                       if(weekendDayStyle!=null)\r
-                       {\r
-                               weekendDayStyle.TrackViewState();\r
-                       }\r
-                       if(otherMonthDayStyle!=null)\r
-                       {\r
-                               otherMonthDayStyle.TrackViewState();\r
-                       }\r
-                       if(selectedDayStyle!=null)\r
-                       {\r
-                               selectedDayStyle.TrackViewState();\r
-                       }\r
-                       if(selectorStyle!=null)\r
-                       {\r
-                               selectorStyle.TrackViewState();\r
-                       }\r
-               }\r
-\r
-               private void RenderAllDays (HtmlTextWriter writer,\r
-                                           DateTime firstDay,\r
-                                           DateTime activeDate,\r
-                                           CalendarSelectionMode mode,\r
-                                           bool isActive,\r
-                                           bool isDownLevel)\r
-               {\r
-                       TableItemStyle weeksStyle = null;
-                       TableCell weeksCell = new TableCell ();\r
-                       TableItemStyle weekendStyle = WeekendDayStyle;\r
-                       TableItemStyle otherMonthStyle = OtherMonthDayStyle;\r
-                       Unit size;\r
-                       bool isWeekMode = (mode == CalendarSelectionMode.DayWeek ||\r
-                                          mode == CalendarSelectionMode.DayWeekMonth);\r
-\r
-                       if (isWeekMode) {\r
-                               weeksStyle = new TableItemStyle ();\r
-                               weeksStyle.Width = Unit.Percentage (12);\r
-                               weeksStyle.HorizontalAlign = HorizontalAlign.Center;\r
-                               weeksStyle.CopyFrom (SelectorStyle);\r
-                               size = Unit.Percentage (12);\r
-                       } else {\r
-                               size = Unit.Percentage (14);\r
-                       }\r
-\r
-                       TableItemStyle [] styles = new TableItemStyle [32];\r
-                       int definedStyles = MASK_SELECTED;\r
-                       if (weekendStyle != null && !weekendStyle.IsEmpty)\r
-                               definedStyles |= MASK_WEEKEND;\r
-                       if (otherMonthStyle != null && !otherMonthStyle.IsEmpty)\r
-                               definedStyles |= MASK_OMONTH;\r
-                       if (todayDayStyle != null && !todayDayStyle.IsEmpty)\r
-                               definedStyles |= MASK_TODAY;\r
-                       if (dayStyle != null && !dayStyle.IsEmpty)\r
-                               definedStyles |= MASK_DAY;\r
-\r
-                       int month = globCal.GetMonth (activeDate);\r
-                       DateTime currentDay = firstDay;\r
-                       int begin = (int) (firstDay - begin_date).TotalDays;
-                       for (int crr = 0; crr < 6; crr++) {\r
-                               writer.Write ("<tr>");\r
-                               if (isWeekMode) {\r
-                                       int week_offset = begin + crr * 7;
-                                       string cellText = GetCalendarLinkText (\r
-                                                               "R" + week_offset + "07",\r
-                                                               SelectWeekText, \r
-                                                               "Select week " + (crr + 1),\r
-                                                               weeksCell.ForeColor,\r
-                                                               isActive);\r
-\r
-                                       weeksCell.Text = cellText;\r
-                                       weeksCell.ApplyStyle (weeksStyle);
-                                       RenderCalendarCell (writer, weeksCell, cellText);\r
-                               }\r
-\r
-                               for (int weekDay = 0; weekDay < 7; weekDay++) {\r
-                                       string dayString = currentDay.Day.ToString ();\r
-                                       DayOfWeek dow = currentDay.DayOfWeek;
-                                       CalendarDay calDay =\r
-                                               new CalendarDay (\r
-                                                               currentDay,\r
-                                                               dow == DayOfWeek.Sunday ||
-                                                               dow == DayOfWeek.Saturday,
-                                                               currentDay == TodaysDate, \r
-                                                               SelectedDates.Contains (currentDay),\r
-                                                               globCal.GetMonth (currentDay) != month,\r
-                                                               dayString\r
-                                                               );\r
-\r
-\r
-                                       int dayStyles = GetMask (calDay) & definedStyles;\r
-                                       TableItemStyle currentDayStyle = styles [dayStyles];\r
-                                       if (currentDayStyle == null) {\r
-                                               currentDayStyle = new TableItemStyle ();\r
-                                               if ((dayStyles & MASK_DAY) != 0)\r
-                                                       currentDayStyle.CopyFrom (DayStyle);\r
-\r
-                                               if ((dayStyles & MASK_WEEKEND) != 0)\r
-                                                       currentDayStyle.CopyFrom (WeekendDayStyle);\r
-\r
-                                               if ((dayStyles & MASK_TODAY) != 0)\r
-                                                       currentDayStyle.CopyFrom (TodayDayStyle);\r
-\r
-                                               if ((dayStyles & MASK_OMONTH) != 0)\r
-                                                       currentDayStyle.CopyFrom (OtherMonthDayStyle);\r
-\r
-                                               if ((dayStyles & MASK_SELECTED) != 0) {\r
-                                                       currentDayStyle.ForeColor = Color.White;\r
-                                                       currentDayStyle.BackColor = Color.Silver;\r
-                                                       currentDayStyle.CopyFrom (SelectedDayStyle);\r
-                                               }\r
-\r
-                                               currentDayStyle.Width = size;\r
-                                               currentDayStyle.HorizontalAlign = HorizontalAlign.Center;\r
-                                       }\r
-\r
-                                       TableCell dayCell = new TableCell ();
-                                       dayCell.ApplyStyle (currentDayStyle);
-                                       dayCell.Controls.Add (new LiteralControl (dayString));
-                                       calDay.IsSelectable = isActive;
-                                       if (calDay.IsSelectable)
-                                               dayCell.Text = GetCalendarLinkText (
-                                                                       (begin + (crr * 7 + weekDay)).ToString (),
-                                                                       dayString,\r
-                                                                       currentDay.ToShortDateString (),
-                                                                       dayCell.ForeColor,
-                                                                       isActive);
-
-                                       OnDayRender (dayCell, calDay);
-                                       dayCell.RenderControl (writer);
-
-                                       currentDay = globCal.AddDays (currentDay, 1);\r
-                               }\r
-                               writer.Write("</tr>");\r
-                       }\r
-               }\r
-\r
-               private int GetMask (CalendarDay day)\r
-               {\r
-                       int retVal = MASK_DAY;\r
-                       if(day.IsSelected)\r
-                               retVal |= MASK_SELECTED;\r
-                       if(day.IsToday)\r
-                               retVal |= MASK_TODAY;\r
-                       if(day.IsOtherMonth)\r
-                               retVal |= MASK_OMONTH;\r
-                       if(day.IsWeekend)\r
-                               retVal |= MASK_WEEKEND;\r
-                       return retVal;\r
-               }\r
-\r
-               /// <remarks>\r
-               /// Refers to the second line of the calendar, that contains a link\r
-               /// to select whole month, and weekdays as defined by DayNameFormat\r
-               /// </remarks>\r
-               private void RenderHeader (HtmlTextWriter writer,\r
-                                          DateTime firstDay,\r
-                                          CalendarSelectionMode mode,\r
-                                          bool isActive,\r
-                                          bool isDownLevel)\r
-               {\r
-                       writer.Write("<tr>");\r
-                       bool isWeekMode = (mode == CalendarSelectionMode.DayWeek ||\r
-                                          mode == CalendarSelectionMode.DayWeekMonth);\r
-\r
-                       TableCell headerCell = new TableCell ();\r
-                       headerCell.HorizontalAlign = HorizontalAlign.Center;\r
-                       string selMthText = String.Empty;\r
-                       if (isWeekMode) {\r
-                               if (mode == CalendarSelectionMode.DayWeekMonth) {\r
-                                       DateTime visDate = GetEffectiveVisibleDate ();
-                                       DateTime sel_month = new DateTime (visDate.Year, visDate.Month, 1);
-                                       int month_offset = (int) (sel_month - begin_date).TotalDays;
-                                       headerCell.ApplyStyle (SelectorStyle);\r
-                                       selMthText = GetCalendarLinkText ("R" + month_offset +
-                                                       globCal.GetDaysInMonth (sel_month.Year,
-                                                                       sel_month.Month).ToString ("d2"), // maybe there are calendars with less then 10 days in a month
-                                                                         SelectMonthText,\r
-                                                                         "Select the whole month",\r
-                                                                         SelectorStyle.ForeColor,\r
-                                                                         isActive);\r
-                               } else {\r
-                                       headerCell.ApplyStyle (DayHeaderStyle);\r
-                                       selMthText = String.Empty;\r
-                               }\r
-                               RenderCalendarCell (writer, headerCell, selMthText);\r
-                       }\r
-\r
-                       TableCell dayHeaderCell = new TableCell ();\r
-                       dayHeaderCell.HorizontalAlign = HorizontalAlign.Center;\r
-                       dayHeaderCell.ApplyStyle (dayHeaderStyle);
-\r
-                       int dayOfWeek = (int) globCal.GetDayOfWeek (firstDay);\r
-                       DateTimeFormatInfo currDTInfo = DateTimeFormatInfo.CurrentInfo;\r
-                       for(int currDay = dayOfWeek; currDay < dayOfWeek + 7; currDay++) {\r
-                               DayOfWeek effDay = (DayOfWeek) Enum.ToObject (typeof (DayOfWeek), currDay % 7);\r
-                               string currDayContent;\r
-                               switch(DayNameFormat) {\r
-                               case DayNameFormat.Full:\r
-                                       currDayContent = currDTInfo.GetDayName (effDay);\r
-                                       break;\r
-                               case DayNameFormat.FirstLetter:\r
-                                       currDayContent = currDTInfo.GetDayName (effDay).Substring (0,1);\r
-                                       break;\r
-                               case DayNameFormat.FirstTwoLetters:\r
-                                       currDayContent = currDTInfo.GetDayName (effDay).Substring (0,2);\r
-                                       break;\r
-                               case DayNameFormat.Short:\r
-                                       goto default;\r
-                               default:\r
-                                       currDayContent = currDTInfo.GetAbbreviatedDayName (effDay);\r
-                                       break;\r
-                               }\r
-\r
-                               RenderCalendarHeaderCell (writer, dayHeaderCell, currDayContent, currDTInfo.GetDayName (effDay));\r
-                       }\r
-                       writer.Write ("</tr>");\r
-               }\r
-\r
-               private void RenderTitle (HtmlTextWriter writer,\r
-                                         DateTime visibleDate,\r
-                                         CalendarSelectionMode mode,\r
-                                         bool isActive)\r
-               {\r
-                       writer.Write("<tr>");\r
-                       Table innerTable = new Table ();\r
-                       TableCell titleCell = new TableCell();\r
-                       bool isWeekMode = (mode == CalendarSelectionMode.DayWeek ||\r
-                                          mode == CalendarSelectionMode.DayWeekMonth);\r
-\r
-                       titleCell.ColumnSpan = (isWeekMode ? 8 : 7);\r
-                       titleCell.BackColor = Color.Silver;\r
-\r
-                       innerTable.GridLines = GridLines.None;\r
-                       innerTable.Width = Unit.Percentage (100);\r
-                       innerTable.CellSpacing = 0;\r
-                       ApplyTitleStyle (innerTable, titleCell, TitleStyle);\r
-\r
-                       titleCell.RenderBeginTag (writer);\r
-                       innerTable.RenderBeginTag (writer);\r
-\r
-                       writer.Write ("<tr>");\r
-                       string prevContent = String.Empty;\r
-                       if (ShowNextPrevMonth) {\r
-                               TableCell prevCell = new TableCell ();\r
-                               prevCell.Width = Unit.Percentage (15);\r
-                               prevCell.HorizontalAlign = HorizontalAlign.Left;\r
-                               if (NextPrevFormat == NextPrevFormat.CustomText) {\r
-                                       prevContent = PrevMonthText;\r
-                               } else {\r
-                                       int pMthInt = globCal.GetMonth(globCal.AddMonths (visibleDate, -1));\r
-                                       if (NextPrevFormat == NextPrevFormat.FullMonth)\r
-                                               prevContent = infoCal.GetMonthName (pMthInt);\r
-                                       else\r
-                                               prevContent = infoCal.GetAbbreviatedMonthName (pMthInt);\r
-                               }\r
-                               DateTime prev_month = visibleDate.AddMonths (-1);
-                               int prev_offset = (int) (new DateTime (prev_month.Year,
-                                                                         prev_month.Month, 1) - begin_date).TotalDays;
-                               prevCell.ApplyStyle (NextPrevStyle);\r
-                               RenderCalendarCell (writer,\r
-                                                   prevCell,\r
-                                                   GetCalendarLinkText ("V" + prev_offset,\r
-                                                                        prevContent,\r
-                                                                                "Go to previous month",\r
-                                                                        NextPrevStyle.ForeColor,\r
-                                                                        isActive)\r
-                                                   );\r
-                       }\r
-\r
-                       TableCell currCell = new TableCell ();\r
-                       currCell.Width = Unit.Percentage (70);\r
-                       if (TitleStyle.HorizontalAlign == HorizontalAlign.NotSet)\r
-                               currCell.HorizontalAlign = HorizontalAlign.Center;\r
-                       else\r
-                               currCell.HorizontalAlign = TitleStyle.HorizontalAlign;\r
-\r
-                       currCell.Wrap = TitleStyle.Wrap;\r
-                       string currMonthContent = String.Empty;\r
-                       if (TitleFormat == TitleFormat.Month) {\r
-                               currMonthContent = visibleDate.ToString ("MMMM");\r
-                       } else {\r
-                               string cmcFmt = infoCal.YearMonthPattern;\r
-                               if (cmcFmt.IndexOf (',') >= 0)\r
-                                       cmcFmt = "MMMM yyyy";\r
-\r
-                               currMonthContent = visibleDate.ToString (cmcFmt);\r
-                       }\r
-\r
-                       RenderCalendarCell (writer, currCell, currMonthContent);\r
-                                                                \r
-                       string nextContent = String.Empty;\r
-                       if (ShowNextPrevMonth) {\r
-                               TableCell nextCell = new TableCell ();\r
-                               nextCell.Width = Unit.Percentage(15);\r
-                               nextCell.HorizontalAlign = HorizontalAlign.Right;\r
-                               if (NextPrevFormat == NextPrevFormat.CustomText) {\r
-                                       nextContent = NextMonthText;\r
-                               } else {\r
-                                       int nMthInt = globCal.GetMonth (globCal.AddMonths (visibleDate, 1));\r
-                                       if(NextPrevFormat == NextPrevFormat.FullMonth)\r
-                                               nextContent = infoCal.GetMonthName(nMthInt);\r
-                                       else\r
-                                               nextContent = infoCal.GetAbbreviatedMonthName(nMthInt);\r
-                               }\r
-                               DateTime next_month = visibleDate.AddMonths (1);
-                               int next_offset = (int) (new DateTime (next_month.Year,
-                                                                         next_month.Month, 1) - begin_date).TotalDays;
-                               nextCell.ApplyStyle(NextPrevStyle);\r
-                               RenderCalendarCell (writer,\r
-                                                   nextCell,\r
-                                                   GetCalendarLinkText ("V" + next_offset,\r
-                                                                        nextContent,\r
-                                                                        "Go to next month",\r
-                                                                        NextPrevStyle.ForeColor,\r
-                                                                        isActive)\r
-                                                   );\r
-                       }\r
-\r
-                       writer.Write("</tr>");\r
-                       innerTable.RenderEndTag(writer);\r
-                       titleCell.RenderEndTag(writer);\r
-\r
-                       writer.Write("</tr>");\r
-               }\r
-\r
-               private void ApplyTitleStyle(Table table, TableCell cell, TableItemStyle style)\r
-               {\r
-                       if(style.BackColor != Color.Empty)\r
-                       {\r
-                               cell.BackColor = style.BackColor;\r
-                       }\r
-                       if(style.BorderStyle != BorderStyle.NotSet)\r
-                       {\r
-                               cell.BorderStyle = style.BorderStyle;\r
-                       }\r
-                       if(style.BorderColor != Color.Empty)\r
-                       {\r
-                               cell.BorderColor = style.BorderColor;\r
-                       }\r
-                       if(style.BorderWidth != Unit.Empty)\r
-                       {\r
-                               cell.BorderWidth = style.BorderWidth;\r
-                       }\r
-                       if(style.Height != Unit.Empty)\r
-                       {\r
-                               cell.Height = style.Height;\r
-                       }\r
-                       if(style.VerticalAlign != VerticalAlign.NotSet)\r
-                       {\r
-                               cell.VerticalAlign = style.VerticalAlign;\r
-                       }\r
-\r
-                       if(style.ForeColor != Color.Empty)\r
-                       {\r
-                               table.ForeColor = style.ForeColor;\r
-                       } else if(ForeColor != Color.Empty)\r
-                       {\r
-                               table.ForeColor = ForeColor;\r
-                       }\r
-
-                       if (style.CssClass != "") {
-                               cell.CssClass = style.CssClass;
-                       }
-\r
-                       table.Font.CopyFrom(style.Font);\r
-                       table.Font.MergeWith(Font);\r
-               }\r
-\r
-               private void RenderCalendarHeaderCell (HtmlTextWriter writer, TableCell cell, string text, string altText)\r
-               {\r
-#if NET_2_0\r
-                       if (UseAccessibleHeader) {\r
-                               writer.AddAttribute ("align", "center");\r
-                               writer.AddAttribute ("abbr", altText);\r
-                               writer.AddAttribute ("scope", "column");\r
-                               writer.RenderBeginTag (HtmlTextWriterTag.Th);\r
-                               writer.Write (text);\r
-                               writer.RenderEndTag ();\r
-                               return;\r
-                       }\r
-#endif\r
-                       RenderCalendarCell (writer, cell, text);\r
-               }\r
-\r
-               private void RenderCalendarCell (HtmlTextWriter writer, TableCell cell, string text)\r
-               {\r
-                       cell.RenderBeginTag(writer);\r
-                       writer.Write(text);\r
-                       cell.RenderEndTag(writer);\r
-               }\r
-\r
-               private DateTime GetFirstCalendarDay(DateTime visibleDate)\r
-               {\r
-                       int fow = (int) FirstDayOfWeek;\r
-                       if (fow == 7)\r
-                               fow = (int) infoCal.FirstDayOfWeek;\r
-\r
-                       int days = (int) globCal.GetDayOfWeek (visibleDate) - fow;\r
-                       if (days <= 0)\r
-                               days += 7;\r
-                       return globCal.AddDays (visibleDate, -days);\r
-               }\r
-\r
-               private DateTime GetEffectiveVisibleDate()\r
-               {\r
-                       DateTime dt = VisibleDate;\r
-                       if (VisibleDate == DateTime.MinValue)\r
-                                dt = TodaysDate;\r
-\r
-                       return globCal.AddDays (dt, 1 - globCal.GetDayOfMonth (dt));\r
-               }\r
-\r
-               /// <summary>\r
-               /// Creates text to be displayed, with all attributes if to be\r
-               /// shown as a hyperlink\r
-               /// </summary>\r
-               private string GetCalendarLinkText (string eventArg,\r
-                                                   string text,\r
-                                                       string altText,\r
-                                                   Color foreground,\r
-                                                   bool isLink)\r
-               {\r
-                       if (isLink) {\r
-                               StringBuilder dispVal = new StringBuilder ();\r
-                               dispVal.Append ("<a href=\"");\r
-                               dispVal.Append (Page.ClientScript.GetPostBackClientHyperlink (this, eventArg));\r
-                               dispVal.Append ("\" style=\"color: ");\r
-                               if (foreground.IsEmpty) {\r
-                                       dispVal.Append (ColorTranslator.ToHtml (defaultTextColor));\r
-                               } else {\r
-                                       dispVal.Append (ColorTranslator.ToHtml (foreground));\r
-                               }\r
-                               dispVal.Append ("\"");\r
-#if NET_2_0\r
-                               if (UseAccessibleHeader) {\r
-                                       dispVal.Append (" title=\"");\r
-                                       dispVal.Append (altText);\r
-                                       dispVal.Append ("\"");\r
-                               }\r
-#endif\r
-                               dispVal.Append (">");\r
-                               dispVal.Append (text);\r
-                               dispVal.Append ("</a>");\r
-                               return dispVal.ToString ();\r
-                       }\r
-                       return text;\r
-               }\r
-\r
-               private string GetHtmlForCell (TableCell cell, bool showLinks)\r
-               {\r
-                       StringWriter sw = new StringWriter ();\r
-                       HtmlTextWriter htw = new HtmlTextWriter (sw);\r
-                       cell.RenderBeginTag (htw);\r
-                       if(showLinks) {\r
-                               htw.Write (GetCalendarLinkText ("{0}", "{1}", "{1}", cell.ForeColor, showLinks));\r
-                       } else {\r
-                               htw.Write ("{0}");\r
-                       }\r
-                       cell.RenderEndTag (htw);\r
-                       return sw.ToString();\r
-               }\r
-\r
-               internal void SelectRangeInternal (DateTime fromDate, DateTime toDate, DateTime visibleDate)\r
-               {\r
-                       TimeSpan span = toDate - fromDate;\r
-                       if (SelectedDates.Count != span.Days + 1 || \r
-                           SelectedDates [0] != fromDate || \r
-                           SelectedDates [SelectedDates.Count - 1] != toDate) {\r
-                               SelectedDates.SelectRange (fromDate, toDate);\r
-                               OnSelectionChanged ();\r
-                       }\r
-               }\r
+                       return base.CreateControlCollection ();
+               }
 
                protected bool HasWeekSelectors (CalendarSelectionMode selectionMode)
                {
-                       return selectionMode == CalendarSelectionMode.DayWeek ||
-                               selectionMode == CalendarSelectionMode.DayWeekMonth;
+                       if (selectionMode == CalendarSelectionMode.DayWeek || selectionMode == CalendarSelectionMode.DayWeekMonth)
+                               return true;
+
+                       return false;
+               }
+               
+#if NET_2_0
+               void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
+               {
+                       RaisePostBackEvent (eventArgument);
+               }
+
+               protected virtual void RaisePostBackEvent (string arg)
+#else
+               void IPostBackEventHandler.RaisePostBackEvent (string arg)
+#endif
+               {
+                       if (arg.Length < 1)
+                               return;
+
+                       if (arg[0] == 'V') { // Goes to Next or Previous month
+                               DateTime prev = VisibleDate;
+                               int days = Int32.Parse (arg.Substring (1));
+                               DateTime dt = GetGlobalCalendar().AddDays (dateZenith, days);
+                               VisibleDate = dt;
+                               OnVisibleMonthChanged (VisibleDate, prev);
+                               return;
+                       }
+
+                       if (arg[0] == 'R') { // Selects a range of dates
+                               string num, date, days;
+                               num = arg.Substring (1);
+                               days = num.Substring (num.Length - 2, 2);
+                               date = num.Substring (0, num.Length - 2);
+                               DateTime d = GetGlobalCalendar().AddDays (dateZenith, Int32.Parse (date));
+                               SelectedDates.SelectRange (d, d.AddDays (Int32.Parse (days)));
+                               OnSelectionChanged ();
+                               return;
+                       }
+
+                       // Selects a single day
+                       int daysFromZenith = Int32.Parse (arg);
+                       DateTime day = GetGlobalCalendar().AddDays (dateZenith, daysFromZenith);
+                       SelectedDates.SelectRange (day, day);
+                       OnSelectionChanged ();
+               }
+
+               protected override void LoadViewState (object savedState)
+               {
+                       object [] states = (object []) savedState;
+
+                       if (states [0] != null)
+                                base.LoadViewState (states [0]);
+
+                       if (states [1] != null)
+                               DayHeaderStyle.LoadViewState (states [1]);
+
+                       if (states [2] != null)
+                               DayStyle.LoadViewState (states [2]);
+
+                       if (states [3] != null)
+                               NextPrevStyle.LoadViewState (states [3]);
+
+                       if (states [4] != null)
+                               OtherMonthDayStyle.LoadViewState (states [4]);
+
+                       if (states [5] != null)
+                               SelectedDayStyle.LoadViewState (states [5]);
+
+                       if (states [6] != null)
+                               TitleStyle.LoadViewState (states [6]);
+
+                       if (states [7] != null)
+                               TodayDayStyle.LoadViewState (states [7]);
+
+                       if (states [8] != null)
+                               SelectorStyle.LoadViewState (states [8]);
+
+                       if (states [9] != null)
+                               WeekendDayStyle.LoadViewState (states [9]);
+
+                       ArrayList array = (ArrayList) ViewState ["SelectedDates"];
+                       if (array != null) {
+                               dateList = array;
+                               selectedDatesCollection = new SelectedDatesCollection (dateList);
+                       }
+               }
+
+               protected virtual void OnDayRender (TableCell cell, CalendarDay day)
+               {
+                       DayRenderEventHandler eh = (DayRenderEventHandler) (Events [DayRenderEvent]);
+                       if (eh != null)
+                               eh (this, new DayRenderEventArgs (cell, day));
+               }
+
+#if NET_2_0
+               protected internal
+#else          
+               protected
+#endif         
+               override void OnPreRender (EventArgs e)
+               {
+                       base.OnPreRender (e);
+               }
+
+               protected virtual void OnSelectionChanged ()
+               {
+                       EventHandler eh = (EventHandler) (Events [SelectionChangedEvent]);
+                       if (eh != null)
+                               eh (this, EventArgs.Empty);
+               }
+
+               protected virtual void OnVisibleMonthChanged (DateTime newDate,  DateTime previousDate)
+               {
+                       MonthChangedEventHandler eh = (MonthChangedEventHandler) (Events [VisibleMonthChangedEvent]);
+                       if (eh != null)
+                               eh (this, new MonthChangedEventArgs (newDate, previousDate));
+               }
+
+#if NET_2_0
+               protected internal
+#else          
+               protected
+#endif         
+               override void Render (HtmlTextWriter writer)
+               {
+                       Table table = new Table ();
+                       table.CellSpacing = CellSpacing;
+                       table.CellPadding = CellPadding;
+                       if (ControlStyleCreated)
+                               table.ControlStyle.CopyFrom (ControlStyle);
+                       table.CopyBaseAttributes (this);
+                       table.ID = ID;
+
+                       if (ShowGridLines)
+                               table.GridLines = GridLines.Both;
+
+                       table.RenderBeginTag (writer);
+
+#if NET_2_0
+                       if (Caption != "")
+                               WriteCaption (writer);
+#endif
+
+                       if (ShowTitle)
+                               WriteTitle (writer);
+
+                       if (ShowDayHeader)
+                               WriteDayHeader (writer);
+
+                       WriteDays (writer);
+
+                       table.RenderEndTag (writer);
+               }
+
+               protected override object SaveViewState ()
+               {
+                       object [] states = new object [10];
+
+                       if (dayHeaderStyle != null)
+                               states [1] = dayHeaderStyle.SaveViewState ();
+
+                       if (dayStyle != null)
+                               states [2] = dayStyle.SaveViewState ();
+
+                       if (nextPrevStyle != null)
+                               states [3] = nextPrevStyle.SaveViewState ();
+
+                       if (otherMonthDayStyle != null)
+                               states [4] = otherMonthDayStyle.SaveViewState ();
+
+                       if (selectedDayStyle != null)
+                               states [5] = selectedDayStyle.SaveViewState ();
+
+                       if (titleStyle != null)
+                               states [6] = titleStyle.SaveViewState ();
+
+                       if (todayDayStyle != null)
+                               states [7] =todayDayStyle.SaveViewState ();
+
+                       if (selectorStyle != null)
+                               states [8] = selectorStyle.SaveViewState ();
+
+                       if (weekendDayStyle != null)
+                               states [9] = weekendDayStyle.SaveViewState ();
+
+                       if (SelectedDates.Count > 0) {
+                               ViewState ["SelectedDates"] = dateList;
+                       }
+
+                       states [0] = base.SaveViewState ();
+
+                       for (int i = 0; i < states.Length; i++) {
+                               if (states [i] != null) {
+                                       return states;
+                               }
+                       }
+
+                       return null;
+               }
+
+               protected override void TrackViewState ()
+               {
+                       base.TrackViewState ();
+
+                       if (dayHeaderStyle != null)
+                               dayHeaderStyle.TrackViewState ();
+
+                       if (dayStyle != null)
+                               dayStyle.TrackViewState ();
+
+                       if (nextPrevStyle != null)
+                               nextPrevStyle.TrackViewState ();
+
+                       if (otherMonthDayStyle != null)
+                               otherMonthDayStyle.TrackViewState ();
+
+                       if (selectedDayStyle != null)
+                               selectedDayStyle.TrackViewState ();
+
+                       if (titleStyle != null)
+                               titleStyle.TrackViewState ();
+
+                       if (todayDayStyle  != null)
+                               todayDayStyle.TrackViewState ();
+
+                       if (selectorStyle != null)
+                               selectorStyle.TrackViewState ();
+
+                       if (weekendDayStyle != null)
+                               weekendDayStyle.TrackViewState ();
                }
-       }\r
-}\r
+
+               //
+               // Private methods
+               //
+               private void WriteDayHeader (HtmlTextWriter writer)
+               {
+                       int i, first;
+                       string dayName;
+                       i = first = (int) (DisplayFirstDayOfWeek);
+                       TableCell cell;
+
+
+                       writer.RenderBeginTag (HtmlTextWriterTag.Tr);
+
+                       if (SelectionMode == CalendarSelectionMode.DayWeek) {
+                               cell = new TableCell();
+                               cell.HorizontalAlign = HorizontalAlign.Center;
+                               cell.ApplyStyle (DayHeaderStyle);
+
+                               // Empty Cell
+                               cell.RenderBeginTag (writer);
+                               cell.RenderEndTag (writer);
+                       } else {
+                               if (SelectionMode == CalendarSelectionMode.DayWeekMonth) {
+                                       TableCell selector = new TableCell ();
+                                       selector.ApplyStyle (SelectorStyle);
+                                       selector.HorizontalAlign = HorizontalAlign.Center;
+
+                                       DateTime date = new DateTime (DisplayDate.Year, DisplayDate.Month, 1); // first date
+                                       int days =  DateTime.DaysInMonth (DisplayDate.Year, DisplayDate.Month);
+
+                                       selector.RenderBeginTag (writer);
+                                       writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + days, SelectMonthText, DayHeaderStyle.ForeColor, Enabled));
+                                       selector.RenderEndTag (writer);
+                               }
+                       }
+
+                       while (true) {
+                               DayOfWeek dayOfWeek = (DayOfWeek) i;
+                               dayName = dateInfo.GetDayName (dayOfWeek);
+
+#if NET_2_0
+                               if (UseAccessibleHeader) {
+                                       writer.AddAttribute (HtmlTextWriterAttribute.Abbr, dayName);
+                                       writer.AddAttribute (HtmlTextWriterAttribute.Scope, "col");
+                                       cell = new TableHeaderCell();
+                               }
+                               else
+#endif
+                                       cell = new TableCell();
+
+                               cell.HorizontalAlign = HorizontalAlign.Center;
+                               cell.ApplyStyle (DayHeaderStyle);
+
+                               cell.RenderBeginTag (writer);
+
+                               switch (DayNameFormat) {
+                               case DayNameFormat.FirstLetter:
+                                       dayName = dayName.Substring (0, 1);
+                                       break;
+                               case DayNameFormat.FirstTwoLetters:
+                                       dayName = dayName.Substring (0, 2);
+                                       break;
+                               case DayNameFormat.Full:
+                                       break;
+                               case DayNameFormat.Short:
+                               default:
+                                       dayName = dateInfo.GetAbbreviatedDayName (dayOfWeek);
+                                       break;
+                               }
+
+                               writer.Write (dayName);
+                               cell.RenderEndTag (writer);
+
+                               if (i >= daysInAWeek - 1) {
+                                       i = 0;
+                               }
+                               else {
+                                       i++;
+                               }
+                               if (i == first)
+                                       break;
+                       }
+
+                       writer.RenderEndTag ();
+               }
+
+               private void WriteDay (DateTime date, HtmlTextWriter writer)
+               {                       
+                       Style style = new Style ();
+                       TableCell cell = new TableCell ();
+
+                       CalendarDay day = new CalendarDay (date,
+                               IsWeekEnd (date.DayOfWeek),
+                               date == TodaysDate, SelectedDates.Contains (date),
+                               GetGlobalCalendar ().GetMonth (DisplayDate) != GetGlobalCalendar ().GetMonth (date),
+                               date.Day.ToString ());
+
+                       day.IsSelectable = SelectionMode != CalendarSelectionMode.None;
+                       cell.HorizontalAlign = HorizontalAlign.Center;
+                       cell.Width = Unit.Percentage (GetCellWidth ());
+
+                       LiteralControl lit = new LiteralControl (day.DayNumberText);
+                       cell.Controls.Add (lit);
+
+                       OnDayRender (cell, day);
+                                       
+                       if (dayStyle != null && !dayStyle.IsEmpty) {
+                               style.CopyFrom (dayStyle);
+                       }
+
+                       if (day.IsWeekend && weekendDayStyle != null && !weekendDayStyle.IsEmpty) {
+                               style.CopyFrom (weekendDayStyle);
+                       }
+
+                       if (day.IsToday && todayDayStyle != null && !todayDayStyle.IsEmpty) {
+                               style.CopyFrom (todayDayStyle);
+                       }
+
+                       if (day.IsOtherMonth && otherMonthDayStyle != null && !otherMonthDayStyle.IsEmpty) {
+                               style.CopyFrom (otherMonthDayStyle);
+                       }
+
+                       if (day.IsSelected && Enabled) {
+                               style.BackColor = Color.Silver;
+                               style.ForeColor = Color.White;
+                               if (selectedDayStyle != null && !selectedDayStyle.IsEmpty) {
+                                       style.CopyFrom (selectedDayStyle);
+                               }
+                       }
+
+                       cell.ApplyStyle (style);
+
+                       lit.Text = BuildLink (GetDaysFromZenith (date).ToString (), day.DayNumberText,
+                                             cell.ForeColor, day.IsSelectable && Enabled);
+
+                       cell.RenderControl (writer);
+               }
+
+               private void WriteDays (HtmlTextWriter writer)
+               {
+                       DateTime date = new DateTime (DisplayDate.Year, DisplayDate.Month, 1); // first date
+                       DateTime lastDate;
+                       TableCell selectorCell = null;
+                       int n;
+
+                       // Goes backwards until we find the date of that is begining of the week
+                       for (n = 0; n < daysInAWeek; n++) {
+                               if (date.DayOfWeek == DisplayFirstDayOfWeek)
+                                       break;
+
+                               date = GetGlobalCalendar().AddDays (date, -1);
+                       }
+                       /* if the start date is the first day of the week, we need to shift backward one more week */
+                       if (n == 0)
+                               date = GetGlobalCalendar().AddDays (date, -1 * daysInAWeek);
+
+                       lastDate = GetGlobalCalendar().AddDays (date, 6 * daysInAWeek); // Always six weeks per months
+
+                       while (true) {
+                               writer.RenderBeginTag (HtmlTextWriterTag.Tr);
+
+                               if (HasWeekSelectors (SelectionMode)) { // Week selector
+                                       if (selectorCell == null) {
+                                               selectorCell = new TableCell ();
+                                               selectorCell.ApplyStyle (SelectorStyle);
+                                               selectorCell.HorizontalAlign = HorizontalAlign.Center;
+                                               selectorCell.Width = Unit.Percentage (GetCellWidth ());
+                                       }
+
+                                       selectorCell.RenderBeginTag (writer);
+                                       writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + "07", SelectWeekText, selectorCell.ForeColor, Enabled));
+                                       selectorCell.RenderEndTag (writer);
+                               }
+
+                               for (int i = 0; i < daysInAWeek; i++) {
+                                       WriteDay (date, writer);
+                                       date = GetGlobalCalendar().AddDays (date, 1);
+                               }
+
+                               writer.RenderEndTag ();
+                               if (date >= lastDate)
+                                       break;
+                       }
+               }
+
+               private string BuildLink (string arg, string text, Color foreColor, bool hasLink)
+               {
+                       string str = string.Empty;
+                       Color clr;
+                       hasLink = (Page != null && hasLink == true) ? true : false;
+
+                       if (hasLink) {
+#if NET_2_0
+                               Page.ClientScript.RegisterForEventValidation(this.UniqueID, arg);
+#endif                 
+                               str = "<a href=\"";
+                               str += Page.ClientScript.GetPostBackClientHyperlink (this, arg);
+                               str += "\"";
+                       
+
+                               if (!foreColor.IsEmpty) {
+                                       clr = foreColor;
+                               } else {
+                                       if (ForeColor.IsEmpty)
+                                               clr = Color.Black;
+                                       else
+                                               clr = ForeColor;
+                               }
+
+                               str += " style=color:" + ColorTranslator.ToHtml (clr);
+                               str += ">";
+                               str += text;
+                               str += "</a>";
+                       }
+                       else 
+                               str += text;
+
+                       return str;
+               }
+
+               private int GetDaysFromZenith (DateTime date)
+               {
+                       TimeSpan span =  date.Subtract (dateZenith);
+                       return span.Days;
+               }
+
+#if NET_2_0
+               void WriteCaption (HtmlTextWriter writer)
+               {
+                       if (CaptionAlign != TableCaptionAlign.NotSet)
+                               writer.AddAttribute (HtmlTextWriterAttribute.Align, CaptionAlign.ToString (CultureInfo.InvariantCulture));
+
+                       writer.RenderBeginTag (HtmlTextWriterTag.Caption);
+                       writer.Write (Caption);
+                       writer.RenderEndTag ();
+               }
+#endif
+
+               private void WriteTitle (HtmlTextWriter writer)
+               {
+                       TableCell cellNextPrev = null;
+                       TableCell titleCell = new TableCell ();
+                       Table tableTitle = new Table ();
+
+                       writer.RenderBeginTag (HtmlTextWriterTag.Tr);
+
+                       titleCell.ColumnSpan = HasWeekSelectors (SelectionMode) ? 8 : 7;
+
+                       if (titleStyle != null && !titleStyle.IsEmpty && !titleStyle.BackColor.IsEmpty) {
+                               titleCell.BackColor = titleStyle.BackColor;
+                       } else {
+                               titleCell.BackColor = Color.Silver;
+                       }
+
+                       titleCell.RenderBeginTag (writer);
+
+                       // Table
+                       tableTitle.Width =  Unit.Percentage (100);
+                       if (titleStyle != null && !titleStyle.IsEmpty) {
+                               tableTitle.ApplyStyle (titleStyle);
+                       }
+
+                       tableTitle.RenderBeginTag (writer);
+                       writer.RenderBeginTag (HtmlTextWriterTag.Tr);
+
+                       if (ShowNextPrevMonth) { // Previous Table Data
+                               cellNextPrev = new TableCell ();
+                               cellNextPrev.ApplyStyle (nextPrevStyle);
+                               cellNextPrev.Width = Unit.Percentage (15);
+
+                               DateTime date = GetGlobalCalendar().AddMonths (DisplayDate, - 1);
+                               date = GetGlobalCalendar().AddDays (date, -DisplayDate.Day + 1);
+                               cellNextPrev.RenderBeginTag (writer);
+                               writer.Write (BuildLink ("V" + GetDaysFromZenith (date), GetNextPrevFormatText (date, false), cellNextPrev.ForeColor, Enabled));
+                               cellNextPrev.RenderEndTag (writer);
+                       }
+
+                       // Current Month Table Data
+                       {
+                               string str;
+                               TableCell cellMonth = new TableCell ();
+                               cellMonth.Width = Unit.Percentage (70);
+                               cellMonth.HorizontalAlign = HorizontalAlign.Center;
+
+                               cellMonth.RenderBeginTag (writer);
+
+                               str = dateInfo.GetMonthName (GetGlobalCalendar ().GetMonth (DisplayDate));
+
+                               if (TitleFormat == TitleFormat.MonthYear)
+                                       str += " " + (DisplayDate.Year.ToString ());
+
+                               writer.Write (str);
+                               cellMonth.RenderEndTag (writer);
+                       }
+
+                       if (ShowNextPrevMonth) { // Next Table Data
+                               DateTime date = GetGlobalCalendar().AddMonths (DisplayDate, + 1);
+                               date = GetGlobalCalendar().AddDays (date, -DisplayDate.Day + 1);
+
+                               cellNextPrev.HorizontalAlign = HorizontalAlign.Right;
+                               cellNextPrev.RenderBeginTag (writer);
+                               writer.Write (BuildLink ("V" + GetDaysFromZenith (date), GetNextPrevFormatText (date, true), cellNextPrev.ForeColor, Enabled));
+                               cellNextPrev.RenderEndTag (writer);
+                       }
+
+                       writer.RenderEndTag ();
+                       tableTitle.RenderEndTag (writer);
+                       titleCell.RenderEndTag (writer);
+                       writer.RenderEndTag (); //tr
+
+               }
+
+
+               private string GetNextPrevFormatText (DateTime date, bool next)
+               {
+                       string text;
+                       switch (NextPrevFormat) {
+                               case NextPrevFormat.FullMonth:
+                                       text = dateInfo.GetMonthName (GetGlobalCalendar ().GetMonth (date));
+                                       break;
+                               case NextPrevFormat.ShortMonth:
+                                       text = dateInfo.GetAbbreviatedMonthName (GetGlobalCalendar ().GetMonth (date));
+                                       break;
+                               case NextPrevFormat.CustomText:
+                               default:
+                                       text = ((next) ? NextMonthText : PrevMonthText);
+                                       break;
+                       }
+
+                       return text;
+               }
+
+               private bool IsWeekEnd (DayOfWeek day)
+               {
+                       return (day == DayOfWeek.Saturday || day == DayOfWeek.Sunday);
+               }
+
+               private double GetCellWidth ()
+               {
+                       return HasWeekSelectors (SelectionMode) ? 100/8 : 100/7;
+               }
+
+               private System.Globalization.Calendar GetGlobalCalendar ()
+               {
+                       return DateTimeFormatInfo.CurrentInfo.Calendar;
+               }
+
+               [WebSysDescription ("")]
+               [WebCategory ("Action")]
+               public event DayRenderEventHandler DayRender {
+                       add {
+                               Events.AddHandler (DayRenderEvent, value);
+                       }
+                       remove {
+                               Events.RemoveHandler (DayRenderEvent, value);
+                       }
+               }
+
+               [WebSysDescription ("")]
+               [WebCategory ("Action")]
+               public event EventHandler SelectionChanged {
+                       add {
+                               Events.AddHandler (SelectionChangedEvent, value);
+                       }
+                       remove {
+                               Events.RemoveHandler (SelectionChangedEvent, value);
+                       }
+               }
+
+               [WebSysDescription ("")]
+               [WebCategory ("Action")]
+               public event MonthChangedEventHandler VisibleMonthChanged {
+                       add {
+                               Events.AddHandler (VisibleMonthChangedEvent, value);
+                       }
+                       remove {
+                               Events.RemoveHandler (VisibleMonthChangedEvent, value);
+                       }
+               }
+       }
+}
+