# How to set a web form control to be dynamically required

**URL:** <https://discuss.workflowgen.com/t/how-to-set-a-web-form-control-to-be-dynamically-required/169>\
**Category:** Visual Studio Web Forms\
**Created:** [February 17, 2009, 7:44am UTC](https://discuss.workflowgen.com/t/how-to-set-a-web-form-control-to-be-dynamically-required/169 "2009-02-17T07:44:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wfg-admin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.workflowgen.com/wfg-admin/32/714_2.png) [@wfg-admin](https://discuss.workflowgen.com/u/wfg-admin)\
**Post date:** [February 17, 2009, 7:44am UTC](https://discuss.workflowgen.com/t/how-to-set-a-web-form-control-to-be-dynamically-required/169/1 "2009-02-17T07:44:00Z")

</div>

Using the WorkflowGen `FORM_FIELDS_REQUIRED` action parameter sets the control to always be required. To dynamically require a control, it must be managed in code-behind, and not with the WorkflowGen `FORM_FIELDS_REQUIRED` action parameter.

To do this, insert a .NET required field validator and set its `ControlToValidate` property to the control that you want to require. In the validation control’s properties window, set the ValidationGroup to `WFGENPage` and Display to `none`. This is to group the validation control to the WorkflowGen validation group. When a user clicks the Submit button, the newly-added validation control’s error message will be combined with WorkflowGen’s required fields error message.

The `.cs` file is where you add a conditional statement to set the validation control’s `Enable` property to `true` or `false` based on the dependent control’s state. For example:

```auto
if (CheckBox1.Checked){
    RequiredFieldValidator1.Enabled = false;
}

```

If you have a Save as Draft button in your form, you have to make sure that the validation control is not enabled; otherwise, .NET will stop the form submission since the form will still be missing a required field. To do this, set the validation control’s `Enable` property to `false` before calling the `SubmitToWorkflow()` method. For example:

```auto
protected void btnDraft_Click(object sender, EventArgs e){
    RequiredFieldValidator1.Enabled = false;
    DRAFT.Text = "YES";
    SubmitToWorkflow();
}

```

---

<div class="post-metadata">

**Author:** ![athomas](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@athomas](https://discuss.workflowgen.com/u/athomas)\
**Post date:** [June 26, 2018, 8:51pm UTC](https://discuss.workflowgen.com/t/how-to-set-a-web-form-control-to-be-dynamically-required/169/2 "2018-06-26T20:51:54Z")

</div>

Where is the validation control’s properties window?
