---
title: Present the context search box
summary: Render and manage the context search textbox, including its watermark/placeholder behaviour and change notification.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Controls.V2.Menu
reference_type: package
operation_id: OP-MENU-003
trigger: "`SAIFMenu.InitializeControls`, invoked from `CreateControls` during `OnLoad`; property access on `ContextValue`."
---

# Present the context search box

Render and manage the context search textbox, including its watermark/placeholder behaviour and change notification. This operation is implemented by `SAIFMenu.InitializeControls`, `SAIFMenu.ContextValue`.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-MENU-003 |
| **Trigger** | `SAIFMenu.InitializeControls`, invoked from `CreateControls` during `OnLoad`; property access on `ContextValue`. |
| **Inputs** | `ContextViewStyle`, `ContextLabel`, `UpperCaseContextValue`, posted textbox value. |
| **Outputs** | Rendered context textbox; `ContextValue` property; `OnContextChanged` event. |
| **Primary components** | `SAIFMenu.InitializeControls`, `SAIFMenu.ContextValue` |
| **Entry point** | `SAIF.Presentation.Web.Controls.V2.Menu/SAIFMenu.vb` |

## Steps

1. Apply the `ContextViewStyle`: `Normal` shows an editable box, `Read_Only` shows a read-only box, `Hidden` hides it. Enforces [BR-MENU-011](../business-rules.md#br-menu-011-the-context-box-supports-three-display-modes).
2. In `Normal` mode with an empty value and a non-empty `ContextLabel`, display the label as watermark text styled `watermark`. Enforces [BR-MENU-012](../business-rules.md#br-menu-012-an-empty-context-box-displays-its-label-as-watermark-text).
3. Attach `OnFocus` / `OnBlur` handlers passing the label (with single quotes escaped) to the watermark scripts. Enforces [BR-MENU-013](../business-rules.md#br-menu-013-the-watermark-clears-on-focus-and-is-restored-on-blur), [BR-MENU-014](../business-rules.md#br-menu-014-single-quotes-in-the-context-label-are-escaped-before-script-emission).
4. Reading `ContextValue` returns `String.Empty` when the box still contains the watermark label, and upper-cases the value when `UpperCaseContextValue` is set. Enforces [BR-MENU-015](../business-rules.md#br-menu-015-a-context-box-showing-its-watermark-label-is-treated-as-empty), [BR-MENU-016](../business-rules.md#br-menu-016-the-context-value-is-upper-cased-when-configured).
5. Setting `ContextValue` trims (and optionally upper-cases) the value and raises `OnContextChanged` with the old and new values. Enforces [BR-MENU-017](../business-rules.md#br-menu-017-setting-the-context-value-raises-oncontextchanged).

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start(["SAIFMenu.InitializeControls"]) --> Style{ContextViewStyle?}
	Style -->|Normal| Editable["Show editable box"]
	Style -->|Read_Only| ReadOnly["Show read-only box"]
	Style -->|Hidden| Hide["Hide the box"]
	Editable --> Empty{Value empty and ContextLabel set?}
	Empty -->|Yes| Watermark["Display label as watermark text"]
	Watermark --> Handlers["Attach OnFocus/OnBlur watermark handlers, escaping quotes"]
	Handlers --> Read["ContextValue read: empty when showing watermark, upper-cased if configured"]
	Read --> SetValue["ContextValue set: trim/upper-case, raise OnContextChanged"]
	SetValue --> End(["Rendered context textbox with ContextValue property"])
	Empty -->|No| Read
```

## Failure and edge-case behavior

- A `ContextLabel` containing characters other than a single quote is emitted into the inline script unescaped ([BR-MENU-014](../business-rules.md#br-menu-014-single-quotes-in-the-context-label-are-escaped-before-script-emission)).

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

## Sources
- `SAIF.Presentation.Web.Controls.V2.Menu/SAIFMenu.vb`
