In this blog, I explained how to how to highlight a weekend days or a specific days in ASP.NET calender control.
Steps
  • Create new ASP.NET Empty Web Application give it to meaning full name.

  • Add new webfrom to your project.

  • Drag and drop Calendar on your design page.

  • Add two properties WeekendDayStyle-BackColor="Yellow", WeekendDayStyle-ForeColor="Black" to your calender control as shown below and run your application.
  1. <asp:Calendar ID="Calendar1" runat="server"
  2. WeekendDayStyle-BackColor="Yellow"
  3. WeekendDayStyle-ForeColor="Green" ></asp:Calendar>
Output
You can achieve the same by using (OnDayRender event) code as mentioned below. Remove WeekendDayStyle-BackColor="Yellow", WeekendDayStyle-ForeColor="Green" from Calender control.
.aspx
  1. <asp:Calendar ID="Calendar1" runat="server" OnDayRender="Calendar1_DayRender"></asp:Calendar>
CodeBehind:
  1. protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
  2. {
  3. if (e.Day.IsWeekend)
  4. {
  5. e.Cell.BackColor = System.Drawing.Color.Yellow;
  6. e.Cell.ForeColor = System.Drawing.Color.Green;
  7. }
  8. }
If you want to Highlight on 'Monday' write the following code in Calendar1_DayRender event. It highlights the the specified day dates.
  1. if (e.Day.Date.DayOfWeek == DayOfWeek.Monday)
  2. {
  3. e.Cell.BackColor = System.Drawing.Color.Yellow;
  4. e.Cell.ForeColor = System.Drawing.Color.Green;
  5. }
I hope you enjoyed it. Please provide your valuable suggestions and feedback.