# How do I set my WorkflowFileUpload control as a required field?

**URL:** <https://discuss.workflowgen.com/t/how-do-i-set-my-workflowfileupload-control-as-a-required-field/180>\
**Category:** Visual Studio Web Forms\
**Created:** [April 2, 2010, 4:25am UTC](https://discuss.workflowgen.com/t/how-do-i-set-my-workflowfileupload-control-as-a-required-field/180 "2010-04-02T04:25:00Z")\
**Posts on this page:** 1\
**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:** [April 2, 2010, 4:25am UTC](https://discuss.workflowgen.com/t/how-do-i-set-my-workflowfileupload-control-as-a-required-field/180/1 "2010-04-02T04:25:00Z")

</div>

### Issue

I cannot set my `WorkflowFileUpload` control to be a required field using the `FORM_FIELDS_REQUIRED` action parameter.

### Solution

The `WorkflowFileUpload` control is not supported by the `FORM_FIELDS_REQUIRED` parameter. However, you can validate your `WorkflowFileUpload` by checking the `.HasFile` property before you call the `SubmitToWorkflow()` method.

You can also create a client-side custom validation to check if a file has been uploaded to the `WorkflowFileUpload` control.

### Example

Assuming you have a `WorkflowFileUpload` control with the ID `UPLOAD1`, add a .NET `CustomValidator` with a `ClientValidationFunction` that validates `UPLOAD1` (see [How can I use a .NET CustomValidator control in my WorkflowGen web form?](https://discuss.workflowgen.com/t/how-can-i-use-a-net-customvalidator-control-in-my-workflowgen-web-form/174)).

In the `.aspx` file, bind this JavaScript function to `ClientValidationFunction` of the `CustomValidator`.

```auto
function ValidateWFGFileUpload(source, arguments)
{
 var ValidateResult = true;
 ValidateResult = CheckUPLOAD();
 arguments.IsValid = ValidateResult;
}

```

In the `.cs` file, add the following under `Page_PreRender()`:

```auto
string WFGFileUploadStatus = UPLOAD1.HasFile.ToString().ToLower();
ClientScript.RegisterClientScriptBlock(typeof(string), "ValidateWFGFileUpload", "function CheckUPLOAD() {return " + WFGFileUploadStatus + "; }", true);

```

Whenever a user uploads a file through `WorkflowFileUpload`, the `.HasFile` property will be set to `True`. You can use the above client script to define the validation result. If you have multiple `WorkflowFileUpload` controls to be validated, you can combine your `FileUpload` status and set it to the client-side script return value.
