2

I have an ASP.NET Calendar control on my web form.

I have defined a date range with a StartDate and an EndDate and now I need to make all the days in between (including the StartDate and EndDate) red.

How I can do this?

1 Answer 1

0

You can handle the Calendar.DayRender event and customize the appearance of the cells within your date range. A complete example is on the MSDN documentation page, but the most important part is:

Sub DayRender(source As Object, e As DayRenderEventArgs)
    ' Change the background color of the days in the month to yellow.
    If Not e.Day.IsOtherMonth And Not e.Day.IsWeekend Then
        e.Cell.BackColor = System.Drawing.Color.Yellow
    End If 
End Sub 'DayRender 

You just need to adapt the If to compare the day to your custom range and change the background color from yellow to red.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.