Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
210
How to add ActivityAdded, ActivityDeleted and ActivityUpdated event handler in code behind.
posted

I am creating my webday views in my code behind as follows:

foreach (DataRow dr in ds.Tables["Examiners"].Rows)

{

// create the Info object (key to the scheduling)

WebScheduleInfo myInfo = new WebScheduleInfo();

// create the SQL provider

WebScheduleSqlClientProvider mySQLCP = new WebScheduleSqlClientProvider();

myInfo.ID = "WebScheduleInfo_" + dr["DataText"].ToString().Replace(" ", "").Replace(".", "");

mySQLCP.ID = "WebScheduleSqlClientProvider_" + dr["DataText"].ToString().Replace(" ", "").Replace(".", "");

// set the active resource

myInfo.ActiveResourceName = dr["DataText"].ToString();

// set some forms

myInfo.ActiveDayUtc = new Infragistics.WebUI.Shared.SmartDate(WebCalendar1.SelectedDate.AddDays(1).ToShortDateString());

//myInfo.GetAppointmentsForDate(currentResource, WebCalendar1.SelectedDate);

myInfo.AppointmentFormPath = "../SchedulerFiles/AppointmentAdd.aspx";

myInfo.ReminderFormPath = "../SchedulerFiles/Reminder.aspx";

// and link the data provider to the info

mySQLCP.WebScheduleInfo = myInfo;

// now connect the SQL provider

mySQLCP.Connect(ConfigurationManager.AppSettings.Get("SchedulerConnectionString").ToString());

// create a day view

WebDayView myDayView = new WebDayView();

myDayView.ID = "WebDayView_" + dr["DataText"].ToString().Replace(" ","").Replace(".","");

// link the day view to the info

myDayView.WebScheduleInfo = myInfo;

// put an identifier on the day view

myDayView.ToolTip = dr["DataText"].ToString();myDayView.CaptionHeaderText = dr["DataText"].ToString();

myDayView.ScrollPosition = -1;

myDayView.WorkingTimeSlotStyle.BackColor = Utilities.GetExaminerColor(dr["DataValue"].ToString());

if (bFirstResource)

{

myDayView.TimeSlotLabelStyle.Width = 40;

myDayView.Width = 160;

myDayView.Height = 380;

}

else

{

myDayView.TimeSlotLabelAreaVisible =
false;

myDayView.Width = 120;

myDayView.Height = 380;

}

myDayView.EnableAutoActivityDialog = true;

myDayView.DayHeaderFormatString = "ddd, MMM d";

bFirstResource = false;

// Add the day view to the place holder

phTimeSlots.Controls.Add(myDayView);

phTimeSlots.Controls.Add(myInfo);

phTimeSlots.Controls.Add(mySQLCP);

mySQLCP.DataBind();

}

This creates all my webdayviews but I need to add an event handler for when the client adds, updates or deletes an appointment. If a drag and drop the WebScheduleInfo on to a page I can hookup the event handler by going to the properties tab and adding on the events the handler for ActivityAdded, ActivityDeleted and ActivityUpdated which in the code view makes the WebScheduleInfo look like this:

<igsch:WebScheduleInfo ID="WebScheduleInfo1" runat="server"

onactivityadded="WebScheduleInfo_SaveAppealsInfo"

onactivitydeleted="WebScheduleInfo_DeleteAppealsInfo"

onactivityupdated="WebScheduleInfo_SaveAppealsInfo">

</igsch:WebScheduleInfo>

How to I do this same thing in the code behind? I have tried to do something like:

myInfo.Attributes.Add("onactivityadded", "WebScheduleInfo_SaveAppealsInfo");

myInfo.Attributes.Add("onactivityupdated", "WebScheduleInfo_SaveAppealsInfo");

myInfo.Attributes.Add("onactivitydeleted", "WebScheduleInfo_DeleteAppealsInfo");

but it doesn't work. It doesn't fire the WebScheduleInfo_SaveAppealsInfo code in the code behind once the Add, Update or Delete fires.

 Any help would be appreicated.

 Thanks!

  • 210
    posted

    Never mind I found it....

     I just need to do it this way

     myInfo.ActivityAdded += new ActivityAddedEventHandler(this.WebScheduleInfo_SaveAppealsInfo);

    myInfo.ActivityUpdated += new ActivityUpdatedEventHandler(this.WebScheduleInfo_SaveAppealsInfo);

    myInfo.ActivityDeleted += new ActivityDeletedEventHandler(this.WebScheduleInfo_DeleteAppealsInfo);