Create forms

Form controls

To add controls programmatically to a form, you use the Telerik.Sitefinity.Modules.Forms.Web.UI.Fields namespace that contains all form controls. The form control classes are listed below:

  • FormTextBox

  • FormMultipleChoice

  • FormCheckboxes

  • FormParagraphTextBox

  • FormDropDownList

  • FormSectionHeader

  • FormInstructionalText

  • FormSubmitButton

Creating a form

To create a form, you must use the FormsManager class. In this example you create a form with a field for entering the name and aSubmit button. You use FormTextBox for the name text field and FormSubmitButton for the Submit button.

To create the form, perform the following:

  1. Create a form in Sitefinity CMS backend by pasting the following code:

  2. Create the controls for the example form and call the CreateForm method by pasting the following code:

In CreateForm, first, you get the FormsManager and verify that the form is not yet created. You edit and check out the form. Then, you add the controls to the form draft by wrapping them in FormDraftControl. You use siblingId to keep the last control in the placeholder where the current control must be placed in. Finally, you check in and publish the form.

In CreateContactForm, first, you set the name, title and success message for the form. Then, you create the name field and the Submitbutton. Once created, you add the controls in a dictionary with the name of the placeholder where they must be placed in. Finally, you callCreateForm to create the form in Sitefinity CMS backend.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?

Next article

Query forms