2006-12-07 Igor Zelmanovich <igorz@mainsoft.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / Calendar.cs
index 66af393d3db2de5fd2a89617dce35ba82c67c712..ef9010ddc3e3b78788d0369f9af991c3269f229b 100644 (file)
@@ -34,6 +34,7 @@ using System.Collections;
 using System.ComponentModel;
 using System.Drawing;
 using System.Security.Permissions;
+using System.Threading;
 
 namespace System.Web.UI.WebControls {
        // CAS
@@ -70,7 +71,7 @@ namespace System.Web.UI.WebControls {
 
                public Calendar ()
                {
-                       dateInfo = new DateTimeFormatInfo ();
+                       dateInfo = Thread.CurrentThread.CurrentUICulture.DateTimeFormat;
                }
 
 #if NET_2_0
@@ -923,7 +924,7 @@ namespace System.Web.UI.WebControls {
                                        int days =  DateTime.DaysInMonth (DisplayDate.Year, DisplayDate.Month);
 
                                        selector.RenderBeginTag (writer);
-                                       writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + days, SelectMonthText, DayHeaderStyle.ForeColor, true));
+                                       writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + days, SelectMonthText, DayHeaderStyle.ForeColor, Enabled));
                                        selector.RenderEndTag (writer);
                                }
                        }
@@ -1014,7 +1015,7 @@ namespace System.Web.UI.WebControls {
                                style.CopyFrom (otherMonthDayStyle);
                        }
 
-                       if (day.IsSelected) {
+                       if (day.IsSelected && Enabled) {
                                style.BackColor = Color.Silver;
                                style.ForeColor = Color.White;
                                if (selectedDayStyle != null && !selectedDayStyle.IsEmpty) {
@@ -1025,7 +1026,7 @@ namespace System.Web.UI.WebControls {
                        cell.ApplyStyle (style);
 
                        lit.Text = BuildLink (GetDaysFromZenith (date).ToString (), day.DayNumberText,
-                                             cell.ForeColor, day.IsSelectable);
+                                             cell.ForeColor, day.IsSelectable && Enabled);
 
                        cell.RenderControl (writer);
                }
@@ -1062,7 +1063,7 @@ namespace System.Web.UI.WebControls {
                                        }
 
                                        selectorCell.RenderBeginTag (writer);
-                                       writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + "07", SelectWeekText, selectorCell.ForeColor, true));
+                                       writer.Write (BuildLink ("R" + GetDaysFromZenith (date) + "07", SelectWeekText, selectorCell.ForeColor, Enabled));
                                        selectorCell.RenderEndTag (writer);
                                }
 
@@ -1084,6 +1085,9 @@ namespace System.Web.UI.WebControls {
                        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 += "\"";
@@ -1162,7 +1166,7 @@ namespace System.Web.UI.WebControls {
                                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, true));
+                               writer.Write (BuildLink ("V" + GetDaysFromZenith (date), GetNextPrevFormatText (date, false), cellNextPrev.ForeColor, Enabled));
                                cellNextPrev.RenderEndTag (writer);
                        }
 
@@ -1190,7 +1194,7 @@ namespace System.Web.UI.WebControls {
 
                                cellNextPrev.HorizontalAlign = HorizontalAlign.Right;
                                cellNextPrev.RenderBeginTag (writer);
-                               writer.Write (BuildLink ("V" + GetDaysFromZenith (date), GetNextPrevFormatText (date, true), cellNextPrev.ForeColor, true));
+                               writer.Write (BuildLink ("V" + GetDaysFromZenith (date), GetNextPrevFormatText (date, true), cellNextPrev.ForeColor, Enabled));
                                cellNextPrev.RenderEndTag (writer);
                        }