How to disable previous dates in Calendar control in ASP.NET
This is a simple code but many people got confused about this inbuilt feature in .NET Calendar control.
We will be using Calendar DayRender control to disable all the previous dates.
First we will add the Calendar control,
<asp:Calendar ID="Calendar1" runat="server" ondayrender="Calendar1_DayRender">
</asp:Calendar>
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.Date < DateTime.Now.Date)
{
e.Day.IsSelectable = false;
e.Cell.ForeColor = System.Drawing.Color.Gray;
}
}
See the Calendar control after disabling the previous dates,
No comments:
Post a Comment