---
title: Form controls
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

List of examples:

### Creating a new form control

```csharp

// Creates a new form control object
FormUserControlInfo newControl = new FormUserControlInfo();

// Sets the form control properties
newControl.UserControlDisplayName = "New control";
newControl.UserControlCodeName = "NewControl";
newControl.UserControlFileName = "~/CMSFormControls/Basic/TextBoxControl.ascx";
newControl.UserControlForText = true;

// Saves the form control to the database
FormUserControlInfoProvider.SetFormUserControlInfo(newControl);

```

[> Back to list of examples](#toc)

### Updating an existing form control

```csharp

// Gets the form control
FormUserControlInfo updateControl = FormUserControlInfoProvider.GetFormUserControlInfo("NewControl");
if (updateControl != null)
{
    // Updates the form control properties
    updateControl.UserControlDisplayName = updateControl.UserControlDisplayName.ToLower();

    // Saves the changes to the database
    FormUserControlInfoProvider.SetFormUserControlInfo(updateControl);
}

```

[> Back to list of examples](#toc)

### Updating multiple form controls

```csharp

// Loads the form controls whose code name starts with 'NewControl'
var formControls = FormUserControlInfoProvider.GetFormUserControls().WhereStartsWith("UserControlCodeName", "NewControl");

// Loops through the form controls
foreach (FormUserControlInfo modifyControl in formControls)
{
    // Updates the properties of the form control
    modifyControl.UserControlDisplayName = modifyControl.UserControlDisplayName.ToUpper();

    // Saves the changes to the database
    FormUserControlInfoProvider.SetFormUserControlInfo(modifyControl);
}

```

[> Back to list of examples](#toc)

### Deleting a form control

```csharp

// Gets the form control
FormUserControlInfo deleteControl = FormUserControlInfoProvider.GetFormUserControlInfo("NewControl");

// Deletes the form control
FormUserControlInfoProvider.DeleteFormUserControlInfo(deleteControl);

```

[> Back to list of examples](#toc)
