Skip to content

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:
  3. For text/edit types: set CssClass = "disabledbackcolor" and ReadOnly = True. (BR-CORE-009)
  4. For SAIFDropDownList, SAIFRadioButton, SAIFRadioButtonList, SAIFCheckBoxList: set ReadOnly = True only. (BR-CORE-009)
  5. For SAIFComboBox / SAIFListBox: set CssClass = "disabledbackcolor" and Enabled = False. (BR-CORE-009)
  6. 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)
    • 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.
  7. 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).
  8. 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.

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.

Sources

  • SAIF.Presentation.Web.Core.Infragistics111/clsControlManager.vb