Form controls


List of examples:

Creating a new form control




// 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.UserControlType = FormUserControlTypeEnum.Input;
newControl.UserControlForText = true;

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


> Back to list of examples

Updating an existing form control




// 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

Updating multiple form controls




// 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

Deleting a form control




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

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


> Back to list of examples