« Integration to WorkflowGen using URLs | Main | User receives a security access error to the portal when the Windows login name does not match the casing of the username in WorkflowGen database. »
Thursday
Apr012010

How do I set my WorkflowGenFileUpload control as a required field? 

Issue

I cannot set my WorkflowGenFileUpload control to be a required field using FORM_FIELDS_REQUIRED action parameter.

Solution

WorkflowGenFileUpload control is not supported by the FORM_FIELDS_REQUIRED parameter. However, you can validate your WorkflowGenFileUpload 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 WorkflowGenFileUpload control.

Example

Assuming you have a WorkflowGenFileUpload control with an ID “UPLOAD1”, add a .NET CustomValidator with ClientValidationFunction that validates UPLOAD1 (please see http://community.workflowgen.com/kb/how-can-i-use-a-net-customvalidator-control-in-my-workflowge.html for detail about CustomValidator).  

C#

(in .aspx file)

Bind this javascript function to ClientValidationFunction of the CustomValidator

 function ValidateWFGFileUpload(source, arguments)

{

    var ValidateResult = true;

    ValidateResult = CheckUPLOAD();

    arguments.IsValid = ValidateResult;

(in .cs file)

Under Page_PreRender(), you add:

 string WFGFileUploadStatus = UPLOAD1.HasFile.ToString().ToLower();

ClientScript.RegisterClientScriptBlock(typeof(string), "ValidateWFGFileUpload", "function CheckUPLOAD() {return " + WFGFileUploadStatus + "; }", true); 

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

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.
Member Account Required
You must have a member account on this website in order to post comments. Log in to your account to enable posting.