---
title: Build the left menu
summary: Construct the `SAIFMenu` control tree — icons, context box, favourites, and applications accordion — on the page lifecycle.
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-002
trigger: "`SAIFMenu.OnInit` (icon/header setup) followed by `OnLoad` (full control tree build) on every page life-cycle pass."
---

# Build the left menu

Construct the `SAIFMenu` control tree — icons, context box, favourites, and applications accordion — on the page lifecycle. This operation is implemented by `SAIFMenu.OnInit`, `SAIFMenu.OnLoad`.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-MENU-002 |
| **Trigger** | `SAIFMenu.OnInit` (icon/header setup) followed by `OnLoad` (full control tree build) on every page life-cycle pass. |
| **Inputs** | Hosting page cast to `ViewPageBase`; navigation data from [Acquire navigation data](acquire-navigation-data.md). |
| **Outputs** | Fully populated `SAIFMenu` control tree, registered client scripts. |
| **Primary components** | `SAIFMenu.OnInit`, `SAIFMenu.OnLoad` |
| **Entry point** | `SAIF.Presentation.Web.Controls.V2.Menu/SAIFMenu.vb` |

## Steps

1. `OnInit` casts the page to `ViewPageBase`, then runs `CreateControlsBegin`, which builds the menu icons (`imgDefaultOnSubmit`, `imgFavoriteConfig`) and the favourites header panel. Enforces [BR-MENU-005](../business-rules.md#br-menu-005-the-hosting-page-must-be-castable-to-viewpagebase), [BR-MENU-006](../business-rules.md#br-menu-006-a-zero-sized-default-submit-button-renders-first).
2. `OnLoad` runs `CreateControls`, which initialises the context textbox (see [Present the context search box](present-the-context-search-box.md)), adds the application links (see [Render the applications accordion](render-the-applications-accordion.md)), adds the favourites (see [Render favourites](render-favourites.md)) and assembles the sections. Enforces [BR-MENU-007](../business-rules.md#br-menu-007-the-left-menu-control-tree-is-rebuilt-on-every-page-load).
3. `OnLoad` registers a hot-key startup script binding `F12` (key code 123, without Ctrl) to select and focus the context textbox, and `Enter` to post back through the hidden `EC` link button. Enforces [BR-MENU-008](../business-rules.md#br-menu-008-f12-without-ctrl-selects-and-focuses-the-context-box), [BR-MENU-009](../business-rules.md#br-menu-009-enter-in-the-context-box-posts-back-through-the-hidden-ec-link-button).
4. `OnLoad` registers the watermark script block (`js_waterMark_Focus` / `js_waterMark_Blur`) once per page. Enforces [BR-MENU-010](../business-rules.md#br-menu-010-watermark-scripts-are-registered-once-per-page).

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Init["OnInit: cast page to ViewPageBase"] --> Begin["CreateControlsBegin: build menu icons and favourites header panel"]
	Begin --> Load["OnLoad: CreateControls"]
	Load --> Context["Initialize context textbox"]
	Load --> Accordion["Add application links"]
	Load --> Favs["Add favourites"]
	Context --> Assemble["Assemble sections"]
	Accordion --> Assemble
	Favs --> Assemble
	Assemble --> Hotkeys["Register F12 and Enter hot-key scripts"]
	Hotkeys --> Watermark["Register watermark script block once per page"]
	Watermark --> End(["Fully populated SAIFMenu control tree"])
```

## Failure and edge-case behavior

- Hosting page is not a `ViewPageBase`: `m_Page` is `Nothing`; `ViewID`-derived session keys fall back to an empty string ([BR-MENU-005](../business-rules.md#br-menu-005-the-hosting-page-must-be-castable-to-viewpagebase), [BR-MENU-036](../business-rules.md#br-menu-036-session-keys-are-namespaced-by-the-pages-viewid)).

## 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`
