IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
To create an event you can use the Native API or the Fluent API.
When creating an event, you must perform the following:
Create new event.
First, you must create new event.
Set the required properties.
When creating a new event, it is recommended to set at least the following properties:
Title
Content
UrlName
City
Country
EventStart
EventEnd
You can also set any other properties (e.g. PublicationDate, ExpirationDate, Description, DateCreated, ContactName, ContactPhone,ContactEmail, EmailAuthor, etc.) in this step.
Save the event.
Save all changes that you have made to the event.
Publish the event.
Finally, you publish the event using the workflow manager.
To create an event using the Native API, you must use the EventsManager class. For more information, see Creating an event using Native API.
To create an event using the Fluent API, you must use the event facade. For more information, see Creating an event using Fluent API.
The examples below show you how to create an event with predefined ID.
NOTE: In the code examples below the ID argument is assigned to the master version of the event.
The following code creates an event with the specified ID, Title, Content, StartDate, EndDate, City and Country through the Native API.
First, you initialize the EventsManager. You create the event using the CreateEvent method of the EventsManager class. Note that you can create an event with either predefined or auto-generated ID depending on which overload of the method you use. The ID argument is assigned to the ID of the master version of the item. Then, you set the properties of the event. It is recommended to set at least the following properties: Title, Content, UrlName, City, Country, EventStart and EventEnd. Then, you save the changes. Finally, to publish the event in live state, you call the MessageWorkflow method of the WorkflowManager class and pass the required parameters.
The following code creates an event with the specified ID, Title, Content, StartDate, EndDate, City and Country through the Fluent API.
First, you initialize the singular facade of the event by calling App.WorkWith().Event(). You create the event using the CreateNew method of the facade. The ID argument is assigned to the master version of the item. Then, you set the properties of the event by calling the Domethod of the facade. It is recommended to set at least the following properties: Title, Content, UrlName, City, Country, EventStart andEventEnd. Then, you save the changes. Finally, to publish the event in live state, you call the MessageWorkflow method of theWorkflowManager class and pass the required parameters.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important