Get FormField values from submitted form responses
You can get the entry values of input fields in a form response.
To do this, follow the procedure:
- In the form code-behind, get an instance of the
FormsManagerclass. - Get the form by form name.
NOTE: Unless specified manually, when adding a field to a form, the
FormFieldname is automatically generated. To find it, in Sitefinity CMS backend, open your form and perfrom the the following:
> - For MVC click *Edit field » Advanced » Model » MetaField » FieldName*
> - For WebForms click *Edit field » Advanced » MetaField » FieldName*
- Get the form response entries by form.
- For each form response entry, get the value of the form response field by using the
GetValuemethod.
Use the following code sample:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Sitefinity.Forms.Model;
using Telerik.Sitefinity.Modules.Forms;
using Telerik.Sitefinity.Model;
namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.Forms
{
public partial class FormsSnippets
{
public static void GetFormFieldValuesFromFormResponses(string formName, string formFieldName)
{
FormsManager formsManager = FormsManager.GetManager();
//Get the Form by Name
var form = formsManager.GetForms().Where(f => f.Name == formName).SingleOrDefault();
//Get the FormEntries for that Form
var records = formsManager.GetFormEntries(form);
// Loop through all the response records for this form
foreach (FormEntry record in records)
{
//Use GetValue() to obtain the Field value
var textBoxValue = record.GetValue(formFieldName);
}
}
}
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
Get started with Integration Hub | Sitefinity Cloud
This free lesson teaches administrators, marketers, and other business professionals how to use Sitefinity Integration Hub to create automated workflows between Sitefinity and other business systems.
Web Security for Sitefinity Administrators
This free lesson teaches administrators the basics about protecting your Sitefinity instance and your 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 ASP.NET Core and take advantage of its decoupled architecture and modern development model.