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
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:
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.
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.
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.
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.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important