Skip to content

Validate a bound control and reflect state

AutoBindControlAncestor.Validate() surfaces the bound business object's own IDataErrorInfo validation messages on the control's UI and on a shared page error label. This library does not define what constitutes invalid data itself — validity is entirely determined by the bound object's own validation implementation.

Field Value
Operation ID OP-AJAX-003
Trigger Invoked from Auto-bind an individual control to its bound object (BindToControl/BindToObject) when auto-validation is enabled, or called explicitly by page code
Inputs IsValid, ErrorMessages (sourced from the bound object's IDataErrorInfo implementation)
Outputs Page error label text (LblErrorMsg), control background color
Primary components AutoBindControlAncestor.Validate, AutoBindControlAncestor.GetErrorMessages, AutoBindControlAncestor.StyleControl
Entry point SAIF.Presentation.Web.Controls.AJAX.Infragistics103\AutoBindControlAncestor.vb

Steps

  1. ErrorMessages getter calls GetErrorMessages(): if IsBound, casts BoundObject to IDataErrorInfo and reads Item(BindProperty) — this is where the business object's own validation/business-rule engine surfaces error text**; the raw error string is split on vbCrLf into an array. This enforces BR-AJAX-001.
  2. Validate() concatenates unique error messages (skipping duplicates already present) into an HTML string.
  3. BindingUtility.SetObjectValue(PageErrorLabel, "Text", messages) writes the combined message to a page control located by PageErrorLabel (searches Page.Controls recursively for a control whose UniqueID case-insensitively matches "LblErrorMsg").
  4. If no such control exists, GetControl returns Nothing and the reflection-based SetObjectValue silently no-ops (swallowed NotSupportedException)*.
  5. StyleControl(IsValid) is called (MustOverride, implemented per concrete control) — colors the underlying editor's BackColor red when invalid, or resets it (Color.FromName("0"), effectively black/default) when valid.

Origin: Step 1's error-text source (the bound business object's IDataErrorInfo.Item implementation) is defined in the referenced business-object library (e.g., SAIF.Business), not this library — the enforcement/business-rule logic there is out of scope for this analysis and not traced here**.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Validate called]) --> Bound{IsBound?}
    Bound -->|No| NoMsgs([ErrorMessages empty])
    Bound -->|Yes| GetErr[Read IDataErrorInfo.Item BindProperty]
    GetErr --> Split[Split error text into messages]
    Split --> Concat[Concatenate unique messages]
    Concat --> WriteLabel[Write combined text to LblErrorMsg]
    WriteLabel --> Style[StyleControl colors background red/default]

Failure and edge-case behavior

  • No page control named LblErrorMsg exists: GetControl returns Nothing; SetObjectValue swallows the resulting NotSupportedException and the message is never displayed*.
  • BoundObject is not bound (IsBound = False): ErrorMessages returns an empty array, so IsValid reports True.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • SAIF.Presentation.Web.Controls.AJAX.Infragistics103\AutoBindControlAncestor.vb
  • SAIF.Presentation.Web.Controls.AJAX.Infragistics103\BindingUtility.vb