Answer: If we want to determine if the selected date is today’s date or a weekend.We can use this code
ASPX Page :
<asp:Calendar runat="server" ID="Calendar2" OnDayRender="RenderDaysEvent" />
Code Behind:
protected void RenderDaysEvent(object sender, DayRenderEventArgs e)
{
if (e.Day.IsToday)
{
e.Cell.Controls.Add(new LiteralControl("<p style=\"color:brown;\">Today's date</p>"));
}
if (e.Day.IsWeekend)
{
e.Cell.Controls.Add(new LiteralControl("<p style=\"color:green;\">Weekend</p>"));
}
}
By using the IsToday and IsWeekend properties we can determine if a particular date is today’s date or weekend respectively and perform our operation
Asked In: While Learning |
Alert Moderator