I am having a problem setting the background color of an appointment when adding it on the server. I found a couple of entries in the forum about changing background color but it is not working for me. I am adding some appointments server side and based on a flag in the class I am pulling data from, I wanted to effectively color code the appointment. Here is my code (item is a custom class containing the data to be used to populate the appointment):
Appointment appt = new Appointment(ucScheduleInfo); appt.StartDateTime = new SmartDate(item.Detail.StartDate); appt.Duration = new TimeSpan(0, 0, item.Detail.Duration); appt.Subject = "Leave Type" + item.Detail.LeaveID.ToString(); appt.EnableReminder = false; appt.Key = String.Format("0,{0}", item.Detail.LeaveID);.... if(item.someflag) { appt.Style.BackColor = System.Drawing.Color.Red; }
The appointment still renders as the default white. What am I missing? Thanks in advance for the help!
Todd
I was having the same problem and I found the solution, in the CSS file for the the webmonth view, its currently set to go an image instead of color on the activity, once I removed that then it takes the color changes.
I am doing something similar, with setting the background color of single and recurring appointments in the DataBinding event. What I really would like to do, however, is handle all of this in the custom data provider class. I can handle single appointments in the OnInitializeActivity method, but still can't do anything about recurring until it gets back to the webscheduleinfo side of things. Any ideas??
-MJC
protected void WebScheduleInfoMain_DataBinding(object sender, EventArgs e){// Get Current WebScheduleInfoWebScheduleInfo caller = (WebScheduleInfo)sender;// Get Current Day from WebScheduleInfoSmartDate currentDay = caller.ActiveDayUtc.ToLocalTime().Date;currentDay.Day = 1;// Go Back One MonthSmartDate startDate = currentDay.AddMonths(-1);currentDay.Day = DateTime.DaysInMonth(currentDay.Year, currentDay.Month);// Go Foreward One MonthSmartDate endDate = currentDay.AddMonths(1);// Little Extra padding for viewable rangestartDate = startDate.AddDays(-15);endDate = endDate.AddDays(15);// Get All Events for Each day in periodwhile (startDate <= endDate){ // Get Events for Date AppointmentsSubsetCollection events = caller.GetAppointmentsForDate(caller.ActiveResource, startDate); // Ready for next Date startDate = startDate.AddDays(1); // Got Events? if (events != null) { // Loop through Appointments foreach (Appointment ev in events) { // Am I dealing with Occurrence if (ev.IsOccurrence) { // Is this the event you want to color bool isMyEvent = DoSomeLogic(); if (isMyEvent) { // Set the style for each occurrence ev.Style.BackColor = myBackColor; ev.Style.ForeColor = myForeColor; } } } }}}
End Sub
I have the same problem:
When I change the information about the appointments, and I refresh the WebSceduleInfo object trought WebAsyncRefreshPanel.
The information in the appointments is changed ( like title ), but it changes the background color without any sense. I put the color of the Appointment in the Title and the color is right, but it isn't displayed right. In the Title there is a DateTime to and it's changed but the colors are messed up.
Regards, Iva