Reputation: 3945
<asp:Calendar ID="calendarToDisplayWorkSiteDates" runat="server">
Bind to a list in code behind - which highlights all the dates in the list.(On screen)
When a user clicks on a date the page re-freshes but the date that the user has just selected changes to the same color 'silver' as dates which are highlighted (through the list).
Is there anyway to change the color so the user can tell which date they have clicked on and which dates are highlighted through the list.
Thank you
TRIED: BackColor="Red" but doesnt work
Upvotes: 1
Views: 10761
Reputation: 19591
Try DayRender
event (Link)
protected void cal_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.IsToday)
e.Cell.BackColor = Color.Red;
else if (e.Day.IsWeekend)
e.Cell.BackColor = Color.Yellow;
else if (e.Day.IsSelected)
e.Cell.BackColor = Color.Orange;
// else if day exists in your list
// Color the cell in different color
}
Upvotes: 3
Reputation: 11
Use the below code to change the color of the selected date.
calendarToDisplayWorkSiteDates.SelectedDayStyle.BackColor = System.Drawing.Color.Green;
Upvotes: 1