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¶
- Read the control's runtime type name via reflection.
- Branch on control-type family for
ProtectItem: - For text/edit types: set
CssClass = "disabledbackcolor"andReadOnly = True. (BR-CORE-009) - For
SAIFDropDownList,SAIFRadioButton,SAIFRadioButtonList,SAIFCheckBoxList: setReadOnly = Trueonly. (BR-CORE-009) - For
SAIFComboBox/SAIFListBox: setCssClass = "disabledbackcolor"andEnabled = False. (BR-CORE-009) - For a plain
DropDownList:- Derive the companion text box ID by upper-casing the control ID and replacing
DDLwithtxt. - 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
Tryblock and leave the drop-down unmodified.
- Derive the companion text box ID by upper-casing the control ID and replacing
UnProtectItemreverses the transformation for the same control-type families (restoresReadOnly = False/Enabled = True/ defaultCssClass, and re-shows the drop-down while hiding the substituted text box).ItemErrormarks 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¶
ProtectItemon a plainDropDownListnever raises to the caller even if the companion text box naming convention is not followed by the page markup.ItemErroris independent of protect/unprotect state — a control can be simultaneously protected and error-marked.
Related documentation¶
Sources¶
SAIF.Presentation.Web.Core.Infragistics111/clsControlManager.vb