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>
No we will see what you have to write under DayRender event,
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,
3 comments:
It was a wonderfull code .It works for me
You have been very helpful. Thanks
It is really a great work and the way in which u r sharing the knowledge is excellent.
Thanks for helping me to understand basic concepts. As a beginner in Dot Net programming your post help me a lot.Thanks for your informative article.
Dot Net Training in chennai | top10 dot net training institutes in chennai
Post a Comment