# Instruction Class

> An object of the Instruction class is an element of the ConditionalInstruction class and represents actions that are execute´d when the corresponding conditions are fulfilled.

- **Product:** TX Text Control .NET Server
- **Section:** Reference
- **Kind:** Class
- **Introduced:** 28.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.Core.SDK` (assembly `TXTextControl.Core.dll`, from the private NuGet feed or Text Control Offline Packages)
- **Package:** `TXTextControl.TextControl.ASP.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Implements:** `System.IComparable`
- **Path:** TX Text Control .NET Server > Reference > TXTextControl > Instruction Class
- **1551 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/llms-full.txt

---

### Description

An object of the Instruction class is an [element](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/conditionalinstruction/instructions-property/llms-full.txt) of the [ConditionalInstruction](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/conditionalinstruction/llms-full.txt) class and represents actions that are execute´d when the corresponding [conditions](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/conditionalinstruction/conditions-property/llms-full.txt) are fulfilled.

To specify such an instruction, the `Instruction` object has to be initialized with a [FormField](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/formfield/llms-full.txt) that is located inside the document. That form field is the object for which the desired actions are executed.

In this context, up to four different types of actions can be executed: Changing the [FormField.Enabled](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/formfield/enabled-property/llms-full.txt) property, marking the form field value as [valid or invalid](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/conditionalinstructioncollection/isvaluevalid-method/llms-full.txt), setting a new value and replacing the [SelectionFormField.Items](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/selectionformfield/items-property/llms-full.txt) array with another string array. On invoking an instance of the `Instruction` class, one of these types has to be set to the `instructionType` parameter by using one of the corresponding [Instruction.InstructionTypes](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/instructiontypes-enumeration/llms-full.txt) enumeration values.

To specify a value that is set by the specified action when the defined requirements of the [ConditionalInstruction.Conditions](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/conditionalinstruction/conditions-property/llms-full.txt) array are fulfilled, the constructor's `instructionValue` parameter must be used. A value that is applied when the corresponding conditions are not fulfilled, can be set by the `elseInstructionValue` parameter of the constructor's second overload.

### Syntax

```csharp
public class Instruction : IComparable
```

```vbnet
Public Class Instruction
    Implements IComparable
```

### Examples

The following example builds a rule around an approval check box in a fillable form.

```csharp
CheckFormField approvalField = new(false) { Name = "Approved" };
textControl.FormFields.Add(approvalField);
Instruction instruction = new(approvalField, Instruction.InstructionTypes.IsEnabled, true);
```

```vbnet
Dim approvalField As New CheckFormField(False) With { .Name = "Approved" }
textControl.FormFields.Add(approvalField)
Dim instruction As New Instruction(approvalField, Instruction.InstructionTypes.IsEnabled, True)
```

---

## In This Section

- [Instruction Constructor](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/constructor/llms-full.txt): Initializes a new instance of the Instruction class to determine an action that is executed when the defined requirements of the ConditionalInstruction.Conditions array are fulfilled or not fulfilled.
- [Instruction.ElseInstructionValue Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/elseinstructionvalue-property/llms-full.txt): Gets the value that is set by the specified action when the defined requirements of the ConditionalInstruction.Conditions array are not fulfilled and the Instruction.IsElseInstructionEnabled property is set to true.
- [Instruction.FormField Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/formfield-property/llms-full.txt): Gets the FormField to which the specified action is executed.
- [Instruction.InstructionType Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/instructiontype-property/llms-full.txt): Gets the type of action to execute. It specifies how the instruction value and else instruction value is applied to the corresponding form field.
- [Instruction.InstructionTypes Enumeration](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/instructiontypes-enumeration/llms-full.txt): Determines the type of action to execute. The enumeration contains the following values:
- [Instruction.InstructionValue Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/instructionvalue-property/llms-full.txt): Gets the value that is set by the specified action when the defined requirements of the ConditionalInstruction.Conditions array are fulfilled.
- [Instruction.IsElseInstructionEnabled Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/iselseinstructionenabled-property/llms-full.txt): Gets or sets a value indicating whether this Instruction allows to execute else instructions. If this property is set to true, the else instruction value is applied by the specified action when the defined requirements of the ConditionalInstruction.Conditions array are not fulfilled. The default value is false, if no else instruction value was set by the instruction constructor. Otherwise true.
- [Instruction.IsFormFieldChangeInstruction Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/isformfieldchangeinstruction-property/llms-full.txt): Gets or sets a value indicating whether this Instruction listens to value changes of the related conditions' form fields. If this property is set to false, the instruction ignores any form field change that would cause an action. Otherwise the corresponding actions are executed. The default value is true.
- [Instruction.IsInitialInstruction Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/isinitialinstruction-property/llms-full.txt): Gets or sets a value indicating whether this Instruction is handled when the document is initialized as a form. By default, all conditional instructions are applied when the document is changed to or loaded as a form. In this context, if this property is set to false, the instruction does not execute any actions, even if the requirements are fulfilled. The default value is true.

---

## Nearby

- **Previous:** [InputPosition.TextPosition Property](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/inputposition/textposition-property/llms-full.txt)
- **Next:** [Instruction Constructor](https://docs.textcontrol.com/tx-text-control-dotnet-server/reference/txtextcontrol/instruction/constructor/llms-full.txt)
