Infragistics(R) NetAdvantage(R) Web Client: ASP.NET
Create an Activity Using Code


Glossary Item Box

You may need to create an Activity server-side in code. The code below shows how to create an activity. For information on how to add the Activity to the WebScheduleInfo™, see How to Add an Activity Server-Side.

Note: Ensure the Activity was affiliated with the active Resource whose scheduling information is currently being viewed. In this example, the Activity was linked to the Unassigned Resource which is always present. However, when you set the ActiveResourceName property on WebScheduleInfo to a different Resource, Activities belonging to the Unassigned Resource would not be shown.

The code below creates a new instance of the Appointment class and sets some of the initial properties on it, including which Resource organizes it.

In Visual Basic:

Imports Infragistics.WebUI.Shared
Imports Infragistics.WebUI.WebSchedule
...
Private Function CreateAppointment() As Appointment
	
	'Create an empty Activity owned by the WebScheduleInfo. 
	Dim appt As New Appointment(Me.WebScheduleInfo1)
	
	
	'Set pertinent properties on the Activity.
	appt.Subject = "My Thirty-Minute Appointment"
	appt.Duration = New TimeSpan(0, 30, 0)
	
	' Set Key property to a unique value on each appointment.
	appt.Key = "100"
	
	
	'Set ResourceKey property to link Activity with organizing Resource.
	appt.ResourceKey = Me.WebScheduleInfo1.VisibleResources.UnassignedResource.Key
	
	
	'Return the newly initialized Activity.
	CreateAppointment = appt
 
End Function

In C#:

using Infragistics.WebUI.Shared;
using Infragistics.WebUI.WebSchedule;
...
private Appointment CreateAppointment()
{
	// Create an empty Activity owned by the WebScheduleInfo.
	Appointment appt = new Appointment(this.WebScheduleInfo1);
	
	// Set pertinent properties on the Activity.
	appt.Subject = "My Thirty-Minute Appointment";
	appt.Duration = new TimeSpan(0, 30, 0);
	
	// Set Key property to a unique value on each appointment.
	appt.Key = "100";
	
	// Set ResourceKey property to link Activity with organizing Resource.
	appt.ResourceKey = this.WebScheduleInfo1.VisibleResources.UnassignedResource.Key;
	
	// Return the newly initialized Activity.
	return appt;
}

E-mail your feedback on this topic.

Opinion about our help? Take our survey.

Copyright © 1996-2009 Infragistics, Inc. All rights reserved.

Build Version: 9.2