1

I want to change the font color of all events on HolidayList when I change selection on dates. If there is any event on selected dates, label5 will also change, but I want to change font color of all events when page loaded.

private Hashtable HolidayList; /*Will be kept all holidays in it.*/
protected void Page_Load(object sender, EventArgs e)
{

   HolidayList = Getholiday();
   string date = calendar.TodaysDate.ToShortDateString();
   if (HolidayList[date] != null) Label5.Text = (string)HolidayList[date];
   else Label5.Text = "";
}


private Hashtable Getholiday() 
 {
     Hashtable holiday = new Hashtable();
     holiday["9/5/2013"] = "Mudirin Ad gunu";
     holiday["9/7/2013"] = "Dostumun Ad gunu";
     holiday["10/28/2013"] = "Tetil";
    return holiday;
 }

protected void calendar_SelectionChanged(object sender, EventArgs e)
{
    string date = calendar.SelectedDate.ToShortDateString();

    if (HolidayList[date] != null) Label5.Text = (string)HolidayList[date];
    else Label5.Text = "";
} 
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Alihuseyn
  • 148
  • 1
  • 9

1 Answers1

2

add DayRender event and you can change font color of holidays as below

 protected void calendar_DayRender(object sender, DayRenderEventArgs e)
    {
        var day = e.Day.Date.ToString("M/d/yyyy");
        HolidayList = Getholiday();
        if (HolidayList[day] != null)
            e.Cell.ForeColor = System.Drawing.Color.Red;
    }
Damith
  • 62,401
  • 13
  • 102
  • 153