WorkflowPage Class Reference

Accessible methods

void FillFormData(DataSet or XmlDocument)

Use this method to load the temporary form data XML file (dataOUT.xml) from the current action working directory into the form data IN parameter. You can use a DataSet or an XmlDocument object to receive the form data.

Refer to the StoragePath WorkflowPage class property for the location of the current action working directory.

protected void Page_Load(object sender, System.EventArgs e)
{
     // ...
     
     // Fill your form data
     FillFormData(formData);
     
     // ...
}

If there is already some data in your DataSet or XmlDocument, the data will be emptied before being filled.

void SaveFieldsData(DataSet)

This method will attempt to find controls in the web form page that have the same ID as the columns of your form data's Table1; when it finds one, it will update the form data value with the control value.

If the DataType property of the column being filled is Date or Double, the data type of the web form value will be validated and formatted using the current culture code before being pushed into the DataSet. If the value is not consistent with the data type, a FormatException is thrown with an appropriate message telling you which field is not a valid date or double value.

For a FileUpload or an HtmlInputFile control, only the file name is being pushed into the dataset, so you still need to call the SaveFileAttachment method in order to save the file into the EFORMASPX storage path.

To use this method, you must use a DataSet as your form data source.

If a ListBox with multiple selection mode or a CheckBoxList is found for a form data, the value will be all of the selected (or checked) values separated by commas.

The following web controls are supported:

  • TextBox

  • Label

  • DropDownList

  • ListBox

  • CheckBox

  • CheckBoxList

  • RadioButton

  • RadioButtonList

  • FileUpload

  • HtmlInputFile

protected void Submit_Click(object sender, System.EventArgs e)
{
    // ...

    // Save the file attachments to EFORMASPX storage path
    this.SaveFileAttachment(TEST_UPLOAD.PostedFile);

    // Automatically update the form data with the web form fields value
    this.SaveFieldsData(formData);

    // ...
}

void BindFormDataToFields(DataSet, bool isPageDataBind = true)

Use this method when you want to bind all of your web form fields automatically using your form data DataSet. The supported controls are exactly the same as those supported by the SaveFieldsData method.

Set the isPageDataBind parameter to false if you want to skip the call of Page.DataBind() at the beginning of this method. Otherwise, by default, a Page.DataBind() is called at the beginning to ensure that other controls are bound before binding your own web form controls. In some cases, a call to the page databind event might not be desired (e.g. skipping the page databind that was already performed before), or if you want to control exactly when to execute the page databind event instead.

protected void Page_Load(object sender, EventArgs e)
{
    // ...

    // Bind the web form controls with the form data on first page load
    if (!Page.IsPostBack)
    {
        BindFormDataToFields(formData);
    }
    
    // ...
}

void SaveFormData(DataSet or XmlDocument)

Use this method to write a form data into the temporary form data XML file (dataOUT.xml) in the current action working directory. You can use a DataSet or an XmlDocument object to update the form data XML file.

protected void Submit_Click(object sender, System.EventArgs e)
{
    // ...
    
    // Usually, you will want to save your form data before submitting
    this.saveFormData(formData);

    // ...
}

void SaveFormData (DataSet, bool saveFieldValues)

Use this method to save the web form field values into a form data (saveFieldValues set to true) then write the form data into the temporary form data XML file (dataOUT.xml) in the current action working directory.

This method overload is only available if your form data is a DataSet object.

You must set the saveFieldValues parameter to true if you want to save the current state of the web form field values into theform data . This will ensure that the form data values are in sync with the values from the web form fields prior to any manipulations of the web form or form data. For example, it is required to save the web form field values when injecting custom data into the form data prior to reloading the web form using the BindFormDataToFields method. Otherwise, the current state of web form field values could be lost after the refresh. In most scenarios, we suggest setting the saveFieldValues parameter to true before any manipulations that could change the web form or form data.

protected void Submit_Click(object sender, System.EventArgs e)
{
    // ...

    // Usually, you will want to update and save your form data before submitting
    this.SaveFormData(formData, true);

    // ...
}

void SubmitToWorkflow()

Use this method when you want to submit the web form to WorkflowGen and redirect from the web form to WorkflowGen.

protected void Submit_Click(object sender, System.EventArgs e)
{
    // ...

    // Submits everything to the workflow and creates the form archive
    // automatically if needed.
    this.SubmitToWorkflow();
    
    // ...
}

void SubmitToWorkflow(isDraftMode)

Use this method when you want to submit the web form to WorkflowGen and redirect from the web form to WorkflowGen in DRAFT mode (isDraftMode set to true). This will skip all of the required fields including GridViews. (This method is available since WorkflowGen.My version 2.2.5.)

protected void Submit_Click(object sender, System.EventArgs e)
{
    // ...

    // Submits everything to the workflow and creates the form archive
    // automatically if needed.
    this.SubmitToWorkflow(true);
    
    // ...
}

void SubmitToWorkflow(DataSet or XmlDocument)

Use this method when you want to submit the web form to WorkflowGen, save your form data, and redirect from the web form to WorkflowGen.

This method overload is only available if your form data is a DataSet object.

protected void Submit_Click(object sender, System.EventArgs e)
{
    // ...

    // Submits everything to the workflow and creates the form archive
    // automatically if needed.
    this.SubmitToWorkflow(formData);
    
    // ...
}

void SubmitToWorkflow(DataSet, Boolean saveFieldValues)

Use this method when you want to submit the web form to WorkflowGen, save your fields' values to your form data (saveFieldValues set to true), save your form data, and then redirect from the web form to WorkflowGen.

protected void Submit_Click(object sender, System.EventArgs e)
{

    // ...

    // Submits everything to the workflow and creates the form archive
    // automatically if needed.
    this.SubmitToWorkflow(formData, true);
    
    // ...
}

string SaveFileAttachment(HttpPostedFile)

Use this method when you want to save a file attachment to the storage path of EFORMASPX in a sub-directory called upload. This method returns the name of the file.

protected void Submit_Click(object sender, System.EventArgs e)
{
    // ...

    // Save the file attachment to EFORMASPX
    SaveFileAttachment(TEST_UPLOAD.PostedFile);

    // ...
}

string SaveFileAttachment (HttpPostedFile, string)

Use this method when you want to save a file attachment to the storage path of EFORMASPX in a sub-directory called upload and you want to specify a file name to use. This method returns the name of the file.

protected void Submit_Click(object sender, System.EventArgs e)
{
    // ...

    // Save the file attachment to EFORMASPX
    SaveFileAttachment(TEST_UPLOAD.PostedFile, "fileName.ext");

    // ...
}

Overridable methods

string GetFormArchive()

Override this method if you want to customize the output of the form archive. This method has to return a complete HTML page.

protected override string GetFormArchive()
{
    StringBuilder htmlContent = new StringBuilder();

    // Build any HTML code you want inside the htmlContent object
    // ...
    
    return htmlContent.ToString();
}

void ChangeFormArchiveLayout()

Override this method in order to customize the form archive layout.

protected override void ChangeFormArchiveLayout()
{
    // Perform custom treatments here
    // ...

    // Make sure you call the base ChangeFormArchiveLayout if you want the
    // fields to automatically be put to read-only and hide fields that are
    // listed in FORM_ARCHIVE_HIDDEN_FIELDS

    base.ChangeFormArchiveLayout();
}

void ChangeFormLayout()

Override this method in order to customize your web form layout.

protected override void ChangeFormLayout()
{
    // Make sure you call the base ChangeFormLayout before doing anything else
    // because if you call it at the end, you will override your custom changes.
    base.ChangeFormArchiveLayout();    

    // Perform custom treatments here
    // e.g.:
    if (CurrentWorkflowActionName == "ACTION_NAME1")
    {
        // ...
    }
    else if (CurrentWorkflowActionName == "ACTION_NAME2")
    {
        // ...
    }
}

Properties

string CurrentWorkflowActionName (read-only)

  • The name of the current WorkflowGen action.

  • It will be empty if you did not add a CURRENT_ACTION parameter to your action.

if (CurrentWorkflowActionName == "ACTION_NAME")
{
    // ...
}

string LangId (read-only)

  • The current culture code of the connected WorkflowGen user.

  • Culture code example: en-US

if (LangId == "en-US")
{
    // Do some culture-specific treatment...
}

string StoragePath (read-only)

  • The absolute path to the temporary storage folder of the current action working directory. It is used to read and write the form data and to save the file attachments.

  • Value example: DRIVE:\inetpub\wwwroot\wfgen\App_Data\Files\EFORMASPX

FileStream myfs = new FileStream(this.StoragePath + "\\signedXml.xml",
FileMode.Create, FileAccess.ReadWrite);

string RequiredFieldsErrorMessage (read and write)

  • The error message for required fields.

  • Default value: The {0} field is required.

  • This value must contain {0} and will contain the field name.

this.RequiredFieldsErrorMessage = Resources.Strings.RequiredErrorMessage;

string FormArchiveFileName (read and write)

  • The form archive file name.

  • Default value: form_archive.htm

this.FormArchiveFileName = "my_form_archive.htm";

string FormArchiveCssPath (read and write)

  • The relative path to the form archive stylesheet.

  • Default value: \css\form_archive.css

Color ReadOnlyFieldsBorderColor (read and write)

  • The read-only field's border color or text color if it is a drop-down list, checkbox list, or radio button list.

  • If the color is Color.Empty, the color will not be affected.

  • Default value: Color.Empty

this.ReadOnlyFieldsBorderColor = Color.Green;

Color RequiredFieldsBorderColor (read and write)

  • The required field's border color or text color if it is a drop-down list, checkbox list, or radio button list.

  • If the color is Color.Empty, the color will not be affected.

  • Default value: Color.Red

this.RequiredFieldsBorderColor = Color.Orange;

ColorizationType FieldsColorization (read and write)

  • The colorization type for required, read-only, and updatable fields.

  • Possible values: Automatic, Css, None

  • Default value: Automatic

this.FieldsColorization = Fields.ColorizationType.Css;

Boolean IsStandAloneMode (read-only)

  • This property indicates whether or not the web form is running in stand-alone mode.

  • Running in stand-alone mode means that the web form was not instantiated by WorkflowGen, but rather by calling the web form address directly without any WorkflowGen parameters.

if (!this.IsStandAloneMode) 
{
    Page.DataBind();
}

Boolean IsSimpleMode (read and write)

  • This property determines if you are running WorkflowPage in Advanced or Simple mode.

  • This property needs to be determined in the web form's constructor.

  • Default value: true

this.IsSimpleMode = false;

Boolean HandleSubmitButton (read and write)

  • This property determines if WorkflowPage automatically handles the submit button with the ID SubmitButton. If the property is set to true, you don't have to manage the SubmitButton code.

  • This property needs to be determined in the web form's constructor.

  • This property is only available in Simple mode.

  • Default value: true

this.HandleSubmitButton = false;

DataSet FormData (read-only)

  • This property contains the form data DataSet managed by WorkflowPage if you are in Simple mode.

  • This property is only available in Simple mode.

FormData.Tables["Table1"].Rows[0]["REQUEST_DATE"] = DateTime.Now.ToString();

string RequiredGridViewsErrorMessage (read and write)

  • The error message shown to the end-user when a required GridView has not yet been filled in.

  • Default value: The {0} list needs to have at least one filled row.

  • This value must contain {0}; this symbol will contain the field name.

this.RequiredGridViewsErrorMessage =
 Resources.Strings.RequiredGridViewsErrorMessage;

string InvalidNumberGridViewErrorMessage (read and write)

  • The error message shown to the end-user when a numeric field has not been filled with a valid numeric value in a GridView.

  • Default value: You have entered an invalid number in the {0} column.

  • This value must contain {0}; this symbol will contain the field name.

this.InvalidNumberGridViewErrorMessage =
 Resources.Strings.InvalidNumberGVErrMsg;

string InvalidCurrencyGridViewsErrorMessage (read and write)

  • The error message shown to the end-user when a numeric field has not been filled with a valid currency value in a GridView

  • Default value: You have entered an invalid number in the {0} column. Do not enter the currency symbol in the value.

  • This value must contain {0}; this symbol will contain the column header text.

this.InvalidCurrencyGridViewsErrorMessage =
 Resources.Strings.InvalidCurrGVErrMsg;

string RequiredColumnsInGridViewsErrorMessage (read and write)

  • The error message shown to the end-user when a required column has not been filled in a GridView and the end-user tries to update the line

  • Default value: The {0} column is required.

  • This value must contain {0}; this symbol will contain the column header text.

this.RequiredColumnsInGridViewsErrorMessage =
 Resources.Strings.RequiredColInGV;

string InvalidDateGridViewErrorMessage (read and write)

  • The error message shown to the end-user when a date or a date/time field in a GridView has not been filled with a valid date or date/time value

  • Default value: You have entered an invalid date in the {0} column.

  • This value must contain {0}; this symbol will contain the field name.

this.InvalidDateGridViewErrorMessage = Resources.Strings.InvalidDateGVErrMsg;

boolean ColorizeRequiredColumnsInGridViewHeader (read and write)

  • If this property is set to true, the required column headers in the GridViews will have their ForeColor property affected by the RequiredFieldsBorderColor color.

  • Default value: false

  • This property must be determined in the web form's constructor.

  • This property is only available in Simple mode.

this.ColorizeRequiredColumnsInGridViewHeader = true;

string InvalidNumberErrorMessage (read and write)

  • The error message shown to the end-user when a numeric field has not been filled with a valid numeric value.

  • Default value: You have entered an invalid number in the {0} field.

  • This value must contain {0}; this symbol will contain the field name.

this.InvalidNumberErrorMessage = Resources.Strings.InvalidNumberErrMsg;

string InvalidCurrencyErrorMessage (read and write)

  • The error message shown to the end-user when a numeric field has not been filled with a valid currency value.

  • Default value: You have entered an invalid number in the {0} field. Do not enter the currency symbol in the value.

  • This value must contain {0}; this symbol will contain the field name.

this.InvalidCurrencyErrorMessage = Resources.Strings.InvalidCurrencyErrMsg;

string InvalidDateErrorMessage (read and write)

  • The error message shown to the end-user when a date or a date/time field has not been filled with a valid date or date/time value.

  • Default value: You have entered an invalid date in the {0} field.

  • This value must contain {0}; this symbol will contain the field name.

this.InvalidDateErrorMessage = Resources.Strings.InvalidDateErrMsg;

string ParamsXPath (read-only)

  • The value of the ParamsXPath parameter you passed in the WorkflowGen action.

  • Default value: NewDataSet/Table1

boolean IsSessionLess (read and write)

  • If this property is set to true, the ViewState will be used to store all the internal settings for WorkflowPage instead of using the Session.

  • Default value: false

  • This property must be determined in the constructor of the web form.

this.IsSessionLess = true;

boolean SaveFormDataWithSchema (read and write)

  • If this property is set to false, the FormData will be saved without its schema.

  • Default value: true

  • This property must be determined in the constructor of the web form.

this.SaveFormDataWithSchema = false;

boolean RemoveValidatorsInFormArchive (read and write)

  • If this property is set to true, all the validators will be automatically hidden in the form archive.

  • Default value: true

this.RemoveValidatorsInFormArchive = true;

boolean ValidateRequiredFields (read and write)

  • If this property is set to false, all of the required fields' validations will be deactivated except the required fields in the GridView controls.

  • Default value: true

  • This property must be modified before the page's OnLoadComplete event.

this.ValidateRequiredFields = false;

ViewState and Session

WorkflowPage uses the ViewState or the Session, depending on the IsSessionLess property, to store the EFORMASPX parameters it receives and to store some other internal settings it needs to keep, so the ViewState or the Session of the web form should never be deactivated in order to use WorkflowPage.

Be sure to never use the following ViewState or Session variable names:

  • WFGEN_INSTANCE_PATH

  • WFGEN_STORAGE_PATH

  • WFGEN_REPLY_TO

  • WFGEN_CURRENT_ACTION

  • WFGEN_IS_STAND_ALONE

  • WFGEN_GRID_VIEW_INSERTING

  • WFGEN_GRID_VIEW_SHOW_CANCEL

  • WFGEN_PARAMS_XPATH

  • WFGEN_BACKUP_CONTROL_FORECOLOR

  • WFGEN_BACKUP_CONTROL_BORDERCOLOR

  • WFGEN_BACKUP_CONTROL_BACKCOLOR

  • WFGEN_BACKUP_CONTROL_BORDERWIDTH

  • WFGEN_BACKUP_CONTROL_CSSSTYLE

  • WFGEN_BACKUP_CONTROL_CSSCLASS

  • WFGEN_ALL_SIMPLE_MODE_TABLES

  • WFGEN_ALL_SUPPORTED_CONTROLS

  • WFGEN_USER_TZ

  • WFGEN_SIMPLE_MODE_DATASET_STRUCTURE

  • WFGEN_VALIDATE_REQUIRED_FIELDS

  • USER_LANG

Last updated