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¶
ErrorMessagesgetter callsGetErrorMessages(): ifIsBound, castsBoundObjecttoIDataErrorInfoand readsItem(BindProperty)— this is where the business object's own validation/business-rule engine surfaces error text**; the raw error string is split onvbCrLfinto an array. This enforces BR-AJAX-001.Validate()concatenates unique error messages (skipping duplicates already present) into an HTML string.BindingUtility.SetObjectValue(PageErrorLabel, "Text", messages)writes the combined message to a page control located byPageErrorLabel(searchesPage.Controlsrecursively for a control whoseUniqueIDcase-insensitively matches"LblErrorMsg").- If no such control exists,
GetControlreturnsNothingand the reflection-basedSetObjectValuesilently no-ops (swallowedNotSupportedException)*. StyleControl(IsValid)is called (MustOverride, implemented per concrete control) — colors the underlying editor'sBackColorred 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.Itemimplementation) 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
LblErrorMsgexists:GetControlreturnsNothing;SetObjectValueswallows the resultingNotSupportedExceptionand the message is never displayed*. BoundObjectis not bound (IsBound = False):ErrorMessagesreturns an empty array, soIsValidreportsTrue.
Related documentation¶
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.vbSAIF.Presentation.Web.Controls.AJAX.Infragistics103\BindingUtility.vb