How can I display my .NET validator error message dynamically within my webform instead of inside the WorkflowGen popup dialog box?

Question

How can I display my .NET validator error message dynamically within my webform instead of inside the WorkflowGen pop-up dialog box?

Background

Associating your .NET validator to the WFGENPage validationGroup allows for your Submit button (with the samevalidationGroup) to let WorkflowGen catch the error.

If you have the WFGENPage validationGroup assigned to your .NET validator, the validation error message will appear in the standard WorkflowGen error message pop-up dialog box if the submission is triggered by SubmitButton or any button control with the WFGENPage validationGroup.

If you have the WFGENPage validationGroup assigned to a .NET validator and the page is submitted using a Submit button that does not have the WFGENPage validationGroup (or vice-versa), WorkflowGen page will not stop the page from being posted back to the server. As well, the dynamic error message will only be initiated after the page has been posted back.

Solution

If you need to display the validation error message dynamically in the web form without the WorkflowGen standard warning dialog box, you simply do not assign the WFGENPage validationGroup to your validator and Submit button. In this case you will not be able to use FORM_FIELD_REQUIRED to control your web form validation.

Remark

You can only stop the page from being posted back with all your .NET validator messages triggered when both the validator and the submit button are not assigned to WFGENPage ValidationGroup. Otherwise, you will have the error message appear on the form only after the page postback. As well, you can only submit the form if all of the validators’ requirements are fulfilled (e.g. you cannot leave required fields empty when saving as draft).

If you need to have a WorkflowGen submit button to control whether the non-WFGENPage validators are required when submitting (i.e. you want to have a Save button to bypass your own .NET validator), you will need to disable all your .NET validators before calling SubmitToWorkflow() in code-behind.

Considering the following scenario:

  • MyTextBox is a .NET textbox.

  • MyValidator is a .NET required field validator without the WFGENPage validationGroup validating MyTextBox.

  • btnSubmit is a .NET submit button without the WFGENPage validationGroup.

  • btnSave is a .NET submit button that has the WFGENPage validationGroup.

When a user clicks on the btnSubmit button while MyTextBox is empty, the form will not postback, and display the error at MyValidator.

When a user clicks on the btnSave button while MyTextBox is empty, the webform will postback and execute the onclick event for btnSave. If under this onclick event we have:

MyValidator.Enabled = false;
SubmitToWorkflow();

then the page will be submitted to WorkflowGen and ignore the MyValidator validation.

If MyValidator.enable is still true, the page will not submit. Instead, it will perform a post back and then display the error message at MyValidator.

Setting MyValidator's visibility to false will not work.