# How can I use a .NET CustomValidator control in my WorkflowGen web form?

**URL:** https://discuss.workflowgen.com/t/how-can-i-use-a-net-customvalidator-control-in-my-workflowgen-web-form/174
**Category:** Visual Studio Web Forms
**Created:** [June 23, 2009, 6:12am UTC](https://discuss.workflowgen.com/t/how-can-i-use-a-net-customvalidator-control-in-my-workflowgen-web-form/174 "2009-06-23T06:12: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: [June 23, 2009, 6:12am UTC](https://discuss.workflowgen.com/t/how-can-i-use-a-net-customvalidator-control-in-my-workflowgen-web-form/174/1 "2009-06-23T06:12:00Z")

</div>

A `CustomValidator` is similar to other .NET validator controls except that the validation process is controlled by the developers code either at the client-side or server-side.

You can build your validation code at server-side or client-side to stop the form from submitting when an entry is invalid. However, since WorkflowGen’s built-in validation is triggered at the client-side, and in order to combine the validation results to WorkflowGen’s validation dialog box without a page postback, a client-side scripted approach is suggested.

First, add a .NET `CustomValidator` control to your form:

```auto
<asp:CustomValidator ID="cfv" runat="server" ErrorMessage="[YOUR_CUSTOM_ERROR_MESSAGE]" Display="None" Enabled="True" SetFocusOnError="True" ValidationGroup="WFGENPage" ClientValidationFunction="[YOUR_JAVASCRIPT_FUNCTION]">
</asp:CustomValidator>

```

Make sure you change the error message to meet your needs. As well, the `Display` attribute should be set to `None` and the `ValidationGroup` attribute must be set to `WFGENPage` to combine your error message with WorkflowGen’s built-in message dialog box. The `ClientValidationFunction` attribute should be set with the name of your JavaScript function, and not a server-side method name.

Then, in your `.aspx` page, you can add your own JavaScript function. This function should have the following structure:

```auto
function YOUR_JAVASCRIPT_FUNCTION(source, arguments){ var ValidateResult = true; // set ValidateResult this Boolean variable to true or false based on your custom
 // validation rule; arguments.IsValid = ValidateResult; }

```

This JavaScript function receives the source and the arguments as parameters automatically from the `CustomValidator`. It returns the validation result `arguments.IsValid`. If the validation result is `false`, then the error message of your custom validator will appear in the WorkflowGen dialog box when submitting the form.

**Note** : Make sure your web form and WorkflowGen action meet the basic requirement for WorkflowGen built-in validation before adding the custom validator to ensure that the default validation is functioning. For more information, see [My .NET validator does not trigger the validation error message](https://discuss.workflowgen.com/t/my-net-validator-does-not-trigger-the-validation-error-message/354).
