Create form responses

You can create multiple responses for a specific web form to analyze web form analytics and to monitor web form metrics, for example. You can create the required number of form responses all at once in the web form's code-behind.

PREREQUISITES: You created a web form with name testform1, for example, and dragged into the content of the form a textbox with label FirstName, for example. For more information about creating forms programmatically, see For developers: Create forms.

To create form responses:

  1. Create a new web form and in the code-behind of the web form, get an instance of the FormsManager.
  2. Using the web form's name, get the web form that requires responses.
  3. Create a new form entry of type FormEntry.
  4. Set the value of the textbox, the IP address, the time when the response is submitted, and user ID.
  5. Set the language of the entry.
  6. To increase the form entry seed and set the referral code.
  7. Call the SaveChanges method to preserve the changes to the database.

The following code illustrates a implementation of the web form's code-behind:

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

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to 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 form responses