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


#1

Question

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

Background

Associating your .NET validator to ValidationGroup “WFGENPage” allows for your submit button (with the same ValidationGroup) to let WorkflowGen catch the error.

If you have the ValidationGroup “WFGENPage” assigned to your .NET validator, the validation error message will appear in the standard WFG error message popup dialog box if the submission is triggered by SubmitButton or any button control with validationGroup “WFGENPage”.

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. Also 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 on the webform 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 webform 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; also you can only submit the form if all 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 WFGENPage validationGroup validating MyTextBox
  • btnSubmit is a .NET submit button without WFGENPage validationGroup
  • btnSave is a .NET submit button that has 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 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();

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

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

Setting MyValidator’s visibility to false will not work.