---
title: Protect / unprotect a control
summary: Makes a control read-only/disabled with error marking, or reverses that transformation.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Core.Infragistics111
reference_type: package
operation_id: OP-CORE-003
trigger: Called by consuming pages when a field must become read-only, editable, or error-flagged
---

# Protect / unprotect a control

This operation switches a UI control between a protected (read-only/disabled) state and an editable state, adapting its approach per control-type family, and separately marks controls as being in error.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-CORE-003 |
| **Trigger** | Called by consuming pages when a field must become read-only, editable, or error-flagged |
| **Inputs** | Target `Control` |
| **Outputs** | Mutated `CssClass`, `ReadOnly`, `Enabled`, `Visible` properties (and, for drop-downs, a substituted text box) |
| **Primary components** | `Utilities.clsControlManager.ProtectItem`, `Utilities.clsControlManager.UnProtectItem`, `Utilities.clsControlManager.ItemError` |
| **Entry point** | `SAIF.Presentation.Web.Core.Infragistics111/clsControlManager.vb` |

## Steps

1. Read the control's runtime type name via reflection.
2. Branch on control-type family for `ProtectItem`:
   - For text/edit types: set `CssClass = "disabledbackcolor"` and `ReadOnly = True`. ([BR-CORE-009](../business-rules.md#br-core-009-protecting-a-control-makes-it-read-only-or-disabled-and-applies-the-disabled-background))
   - For `SAIFDropDownList`, `SAIFRadioButton`, `SAIFRadioButtonList`, `SAIFCheckBoxList`: set `ReadOnly = True` only. ([BR-CORE-009](../business-rules.md#br-core-009-protecting-a-control-makes-it-read-only-or-disabled-and-applies-the-disabled-background))
   - For `SAIFComboBox` / `SAIFListBox`: set `CssClass = "disabledbackcolor"` and `Enabled = False`. ([BR-CORE-009](../business-rules.md#br-core-009-protecting-a-control-makes-it-read-only-or-disabled-and-applies-the-disabled-background))
   - For a plain `DropDownList`:
     - Derive the companion text box ID by upper-casing the control ID and replacing `DDL` with `txt`.
     - Locate the text box via `Page.FindControl`.
     - Display the drop-down's selected value in the read-only text box and hide the drop-down. ([BR-CORE-010](../business-rules.md#br-core-010-a-protected-dropdownlist-is-hidden-and-replaced-by-a-read-only-text-box-whose-id-is-the-drop-down-id-with-ddl-replaced-by-txt))
     - On failure (companion text box not found, or any exception during substitution): absorb the error in a `Try` block and leave the drop-down unmodified.
3. `UnProtectItem` reverses the transformation for the same control-type families (restores `ReadOnly = False` / `Enabled = True` / default `CssClass`, and re-shows the drop-down while hiding the substituted text box).
4. `ItemError` marks the control with the error CSS class (`errorbackcolor`) so validation failures are visually flagged, independent of the protect/unprotect state.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([ProtectItem called]) --> TypeCheck{Control type?}
	TypeCheck -->|Text/edit| S1["CssClass = disabledbackcolor; ReadOnly = True"]
	TypeCheck -->|SAIFDropDownList/RadioButton/CheckBoxList| S2["ReadOnly = True"]
	TypeCheck -->|SAIFComboBox/SAIFListBox| S3["CssClass = disabledbackcolor; Enabled = False"]
	TypeCheck -->|Plain DropDownList| S4[Derive txt ID: DDL to txt]
	S4 --> Found{Companion text box found?}
	Found -->|Yes| S5[Show value in text box; hide drop-down]
	Found -->|No / error| Absorb([Try/Catch absorbs failure])
```

## Failure and edge-case behavior
- `ProtectItem` on a plain `DropDownList` never raises to the caller even if the companion text box naming convention is not followed by the page markup.
- `ItemError` is independent of protect/unprotect state — a control can be simultaneously protected and error-marked.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `SAIF.Presentation.Web.Core.Infragistics111/clsControlManager.vb`
