---
title: Validate a control and surface errors
summary: Reads validation messages from the bound business object and displays them on the page.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Controls.AJAX.Infragistics111
reference_type: package
operation_id: OP-AJAX-04
trigger: Called from bind or edit operations, or invoked directly
---

# Validate a control and surface errors

This operation reads the bound object's `IDataErrorInfo` error text for the bound property, writes it to the page's error label, and styles the control to reflect its validity.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-AJAX-04 |
| **Trigger** | Called from bind ([OP-AJAX-02](bind-control-to-model-value.md)) or edit ([OP-AJAX-03](push-user-edit-back-to-the-model.md)) operations, or invoked directly |
| **Inputs** | `BoundObject` (`IDataErrorInfo`), `BindProperty` |
| **Outputs** | Page's `LblErrorMsg` label text set; control styled |
| **Primary components** | `AutoBindControlAncestor.Validate`, `GetErrorMessages`, `StyleControl` |
| **Entry point** | `SAIF.Presentation.Web.Controls.AJAX.Infragistics111/AutoBindControlAncestor.vb` |

## Steps

1. Read `ErrorMessages`, which calls `GetErrorMessages`: if the control is bound, cast `BoundObject` to `IDataErrorInfo`, read `Item(BindProperty)`, and split the text on CRLF; if unbound, return an empty array. ([BR-AJAX-008](../business-rules.md#br-ajax-008-validation-messages-come-from-the-bound-objects-idataerrorinfo), [BR-AJAX-009](../business-rules.md#br-ajax-009-an-unbound-control-reports-no-errors))
2. Concatenate the distinct messages with `<br>` separators, skipping any message already present in the accumulated string. ([BR-AJAX-010](../business-rules.md#br-ajax-010-duplicate-validation-messages-are-shown-only-once))
3. Locate the page's `LblErrorMsg` label by recursive `UniqueID` search (case-insensitive) and set its `Text` to the assembled message via `BindingUtility.SetObjectValue`. ([BR-AJAX-011](../business-rules.md#br-ajax-011-validation-messages-are-written-to-the-pages-lblerrormsg-label))
4. Call `StyleControl(IsValid)`; each concrete control paints the editor red when invalid and resets the background otherwise. ([BR-AJAX-012](../business-rules.md#br-ajax-012-an-invalid-editor-is-highlighted-red-a-valid-one-is-reset))
5. Always return `True` — the return value does not report validity.*

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Validate called]) --> Bound{Control bound?}
	Bound -->|No| Empty([No error messages])
	Bound -->|Yes| Read[Read IDataErrorInfo.Item BindProperty]
	Read --> Split[Split on CRLF, dedupe, join with br]
	Split --> Locate[Locate LblErrorMsg by UniqueID search]
	Locate --> SetText[Set label Text]
	SetText --> Style[StyleControl IsValid]
	Style --> EndOk([Return True])
```

## Failure and edge-case behavior
- An unbound control reports no errors and is treated as valid. ([BR-AJAX-009](../business-rules.md#br-ajax-009-an-unbound-control-reports-no-errors))
- The method always returns `True` regardless of actual validity; no caller in this repository appears to use the return value.*

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [SQL catalog](../sql/index.md)
- [Database tables](../database-tables.md)

> **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.Infragistics111/AutoBindControlAncestor.vb`
