> For the complete documentation index, see [llms.txt](https://docs.workflowgen.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.workflowgen.com/vs-web-forms/workflowpage-class-reference.md).

# 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`](/vs-web-forms/workflowpage-class-reference.md#string-storagepath-read-only) WorkflowPage class property for the location of the current action working directory.

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

{% hint style="info" %}
If there is already some data in your DataSet or XmlDocument, the data will be emptied before being filled.
{% endhint %}

### `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`

```csharp
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.

{% hint style="info" %}
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.
{% endhint %}

```csharp
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.

```csharp
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.

{% hint style="warning" %}
You must set the `saveFieldValues` parameter to `true` if you want to save the current state of the web form field values into the`form 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.&#x20;
{% endhint %}

```csharp
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.

```csharp
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.)

```csharp
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.

```csharp
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.

```csharp
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.

```csharp
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.

```csharp
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.

```csharp
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.

```csharp
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.

```csharp
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.<br>
* It will be empty if you did not add a `CURRENT_ACTION` parameter to your action.

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

### `string LangId` (read-only)

* The current culture code of the connected WorkflowGen user.<br>
* Culture code example: `en-US`

```csharp
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.<br>
* Value example: `DRIVE:\inetpub\wwwroot\wfgen\App_Data\Files\EFORMASPX`

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

### `string RequiredFieldsErrorMessage` (read and write)

* The error message for required fields.<br>
* Default value: The `{0}` field is required.<br>
* This value must contain `{0}` and will contain the field name.

```csharp
this.RequiredFieldsErrorMessage = Resources.Strings.RequiredErrorMessage;
```

### `string FormArchiveFileName` (read and write)

* The form archive file name.<br>
* Default value: `form_archive.htm`

```csharp
this.FormArchiveFileName = "my_form_archive.htm";
```

### `string FormArchiveCssPath` (read and write)

* The relative path to the form archive stylesheet.<br>
* 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.<br>
* If the color is `Color.Empty`, the color will not be affected.<br>
* Default value: `Color.Empty`

```csharp
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.<br>
* If the color is `Color.Empty`, the color will not be affected.<br>
* Default value: `Color.Red`

```csharp
this.RequiredFieldsBorderColor = Color.Orange;
```

### `ColorizationType FieldsColorization` (read and write)

* The colorization type for required, read-only, and updatable fields.<br>
* Possible values: `Automatic`, `Css`, `None` <br>
* Default value: `Automatic`

```csharp
this.FieldsColorization = Fields.ColorizationType.Css;
```

### `Boolean IsStandAloneMode` (read-only)

* This property indicates whether or not the web form is running in stand-alone mode.<br>
* 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.

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

### `Boolean IsSimpleMode` (read and write)

* This property determines if you are running WorkflowPage in Advanced or Simple mode.<br>
* This property needs to be determined in the web form's constructor.<br>
* Default value: `true`

```csharp
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.<br>
* This property needs to be determined in the web form's constructor.<br>
* This property is only available in Simple mode.<br>
* Default value: `true`

```csharp
this.HandleSubmitButton = false;
```

### `DataSet FormData` (read-only)

* This property contains the form data DataSet managed by WorkflowPage if you are in Simple mode.<br>
* This property is only available in Simple mode.

```csharp
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.<br>
* Default value: `The {0} list needs to have at least one filled row.` <br>
* This value must contain `{0}`; this symbol will contain the field name.

```csharp
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.<br>
* Default value: `You have entered an invalid number in the {0} column.` <br>
* This value must contain `{0}`; this symbol will contain the field name.

```csharp
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<br>
* Default value: `You have entered an invalid number in the {0} column. Do not enter the currency symbol in the value.` <br>
* This value must contain `{0}`; this symbol will contain the column header text.

```csharp
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<br>
* Default value: `The {0} column is required.` <br>
* This value must contain `{0}`; this symbol will contain the column header text.

```csharp
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<br>
* Default value: `You have entered an invalid date in the {0} column.` <br>
* This value must contain `{0}`; this symbol will contain the field name.

```csharp
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.<br>

* Default value: `false`

* This property must be determined in the web form's constructor.<br>

* This property is only available in Simple mode.

```csharp
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.<br>
* Default value: `You have entered an invalid number in the {0} field.` <br>
* This value must contain `{0}`; this symbol will contain the field name.

```csharp
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.<br>
* Default value: `You have entered an invalid number in the {0} field. Do not enter the currency symbol in the value.` \
  &#x20;
* This value must contain `{0}`; this symbol will contain the field name.

```csharp
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.<br>
* Default value: `You have entered an invalid date in the {0} field.` <br>
* This value must contain `{0}`; this symbol will contain the field name.

```csharp
this.InvalidDateErrorMessage = Resources.Strings.InvalidDateErrMsg;
```

### `string ParamsXPath` (read-only)

* The value of the `ParamsXPath` parameter you passed in the WorkflowGen action.<br>
* 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.<br>

* Default value: `false`

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

```csharp
this.IsSessionLess = true;
```

### `boolean SaveFormDataWithSchema` (read and write)

* If this property is set to `false`, the FormData will be saved without its schema.<br>
* Default value: `true`<br>
* This property must be determined in the constructor of the web form.

```csharp
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.<br>
* Default value: `true`

```csharp
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.<br>
* Default value: `true`<br>
* This property must be modified before the page's `OnLoadComplete` event.

```csharp
this.ValidateRequiredFields = false;
```

## ViewState and Session <a href="#viewstate-session" id="viewstate-session"></a>

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.

{% hint style="warning" %}
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`
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.workflowgen.com/vs-web-forms/workflowpage-class-reference.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
