G Greg Smith Aug 14, 2006 #1 Is there a way to disable past dates for a calendar control, or individual date for that matter? Any help is greatly appreciated.
Is there a way to disable past dates for a calendar control, or individual date for that matter? Any help is greatly appreciated.
M Mark Rae Aug 14, 2006 #2 Is there a way to disable past dates for a calendar control, or individual date for that matter? Click to expand... Dead easy - you need the DayRender method for this. In your HTML: <asp:Calendar ID="MyCalendar" runat="server" OnDayRender="MyCalendar_DayRender" /> And in your code-behind: protected void cal_DayRender(object source, DayRenderEventArgs e) { if (e.Day.Date.Day == 18) { e.Cell.Controls.Clear(); e.Cell.Text = e.Day.DayNumberText; e.Cell.BackColor = System.Drawing.Color.Gainsboro; } } That will disable the 18th of every month. I'm sure you can figure the rest out from that...
Is there a way to disable past dates for a calendar control, or individual date for that matter? Click to expand... Dead easy - you need the DayRender method for this. In your HTML: <asp:Calendar ID="MyCalendar" runat="server" OnDayRender="MyCalendar_DayRender" /> And in your code-behind: protected void cal_DayRender(object source, DayRenderEventArgs e) { if (e.Day.Date.Day == 18) { e.Cell.Controls.Clear(); e.Cell.Text = e.Day.DayNumberText; e.Cell.BackColor = System.Drawing.Color.Gainsboro; } } That will disable the 18th of every month. I'm sure you can figure the rest out from that...