Disable all dates except current date in calender control using c#
You can disable all dates except current date programmatically.You can also change the background color dyanamically.
Calender control
<asp:Calendar ID="Calendar1" runat="server" OnDayRender="Calendar1_DayRender" ></asp:Calendar>
Code Behind
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { if (e.Day.Date > DateTime.Now.Date || e.Day.Date < DateTime.Now.Date) { e.Cell.Enabled = false; //disable current date } else { e.Cell.BackColor = System.Drawing.Color.Blue;//You can change color of the current date } }
Comments
Post a Comment