Register for a Course Use Case
Retired Content |
---|
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
The Register for a Course use case demonstrates how employees can register for a training course. The code that implements this use case demonstrates how an application can query SharePoint list items and add a new item to a list.
Using Custom Action
To begin the registration process, you can use either of two custom actions. One option is to navigate to the DisplayForm.aspx page for a specific training course and select the Register for Course action. The other is to select the Register for Course action from the course's context menu that is located on the training dashboard page or the Training Course list page. You can also make a direct HTTP request for the CourseRegistration.aspx page (http://myserver/sites/training/CourseRegistration.aspx?ID=1). This request initiates the Page_Load handler that validates the request and calculates the fields that are used in the ASPX page. If the request passes this process, the employee sees the course registration form. Figure 1 illustrates the form.
Figure 1
Training Management registration form
Clicking the Register for Course button adds a new item to the SharePoint Registrations list. This list contains items of the application-provided Registration content type.
To define a custom action, use the CustomAction element. The following XML (CourseRegistrationElement.xml) adds the Register for a Course action to the DisplayFormToolbar and to the EditControlBlock. It is located in Contoso.TrainingManagement\Forms\CourseRegistration.
<CustomAction
Id="695F3959-79C5-48b0-AACC-30DF5A731C81"
Location="DisplayFormToolbar"
Title="Register for Course"
RegistrationType="ContentType"
RegistrationId="0x01000CEE433CD7484DC5ADBEC636A5DD0C07">
<UrlAction Url="~site/CourseRegistration.aspx?ID={ItemId}"/>
</CustomAction>
<CustomAction
Id="0F446E21-839F-4938-9F1C-914237F15694"
Location="EditControlBlock"
Title="Register for Course"
RegistrationType="ContentType"
RegistrationId="0x01000CEE433CD7484DC5ADBEC636A5DD0C07">
<UrlAction Url="~site/CourseRegistration.aspx?ID={ItemId}"/>
</CustomAction>
The Id attribute is a programmer-generated GUID. The RegistrationType attribute associates the action with a content type and the RegistrationId attribute is the ID of the training course content type. The UrlAction attribute specifies the HTTP request that is generated when the user selects the action. The {ItemID} expression is replaced at run time with the ID of the selected list item.
Classes Used by the Course Registration Use Case
Figure 2 illustrates the control flow for handling HTTP requests for the Course Registration use case.
Figure 2
Course registration control flow
The arrows in the preceding diagram represent the direction of the control flow. The following five classes are involved in the control flow:
- CourseRegistration. This class is the ASPX page definition produced by the Visual Studio designer. Internet Information Services (IIS) invokes handler methods of the CourseRegistration class when it receives HTTP requests.
- CourseRegistrationPresenter. This is the presenter for the CourseRegistration.aspx page. For more information about the presenter, see Design Patterns and Unit Testing in this guidance.
- TrainingCourseRepository. This class provides Create/Update/Delete operations for the Training Courses SharePoint list.
- RegistrationRepository. This class provides Create/Update/Delete operations for the Registrations SharePoint list.
- ListItemRepository. This class encapsulates some of the details of interacting with SharePoint lists.
Registration Phases
The Registration use case occurs in two phases. They are the Page_Load phase and the Submit_Click phase. These phases correspond to rendering the initial registration page in response to the HTTP request from an employee and to processing the button click when the employee confirms the request for a new registration.
The Registration use case discusses the following topics:
- Course Registration Page Load. This topic explains how a Web page is loaded when an employee submits an HTTP request.
- Adding an Item to the Registration List. This topic explains how a new item is added to the Registrations list. The Registrations list contains course registration requests.
- The Registration Content Type. This topic explains the content type that defines an item in the Registrations list.
- The Registration List. This topic explains the structure of the Registrations list.
Retired Content |
---|
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
To provide feedback, get assistance, or download additional, please visit the SharePoint Guidance Community Web site.
Copyright © 2008 by Microsoft Corporation. All rights reserved.