Datapolis Process System SDK


Home > Custom Controls > Control Code

Control Code



Below you will find basic information about coding custom controls in Datapolis Process System. 



To code custom control you need the following reference in your SharePoint solution project

  • Datapolis.WorkBox.Common  - it provides useful methods and WBCustomFieldControlBase class

This assembly can be found in GAC after Datapolis Process System is installed.


Coding a custom control requires developing a SharePoint User Control that inherits from base class supplied by Datapolis Process System: WBCustomFieldControlBase

public partial class MyCustomFieldControl : WBCustomFieldControlBase
    protected void Page_Load(object sender, EventArgs e)



You need to override 4 methods from base class which contains:

  1. SetDefaultValue
  2. GetValue
  3. IsRequired
  4. Validate

Since custom control is in fact user control it uses ascx markup. Example will consist of one textbox and one dropdown list.

<asp:TextBox runat="server" ID="tbMyValue" Text=""/>
<asp:DropDownList runat="server" ID="ddlMyType">


Overriding methods

​First method is SetDefaultValue. It runs when the form is loaded with current value of workflow variable as an argument.


public override void SetDefaultValue(string value)
    // store default value passed from launch form
    _myValue = new MyValue(value);
    // set controls values
    tbMyValue.Text = _myValue.Value;
    ddlMyType.SelectedValue = _myValue.Type.ToString();


Second method is GetValue. It passes control value to workflow variable. Internally all workflow variables are strings, so you have to parse your value to formatted string.


public override string GetValue()
    // get values from form
    _myValue.Type = (MyDataType)Enum.Parse(typeof(MyDataType), ddlMyType.SelectedValue);
    _myValue.Value = tbMyValue.Text;
    // return formated
    return _myValue.ToString();

Third method is IsRequired. Its purpose is to indicate if a * will be displayed next to field title.


public override bool IsRequired()
    return false;


Last method is Validate. Validation occurs after clicking "Confirm" button on form. If this method returns true, the value will be passed, and the form will be closed. Otherwise validationErrorMsg will be displayed.


public override bool Validate(out string validationErrorMsg)
    // validate value by selected type
    validationErrorMsg = String.Empty;
    bool isValid = false;
    MyDataType type = (MyDataType)Enum.Parse(typeof(MyDataType), ddlMyType.SelectedValue);
    switch (type)
    case MyDataType.Integer:
        int intVal;
        if (int.TryParse(tbMyValue.Text, out intVal))
            isValid = true;
            validationErrorMsg = "Expected integer value.";
    return isValid;