---
title: Render top toolbar menu
summary: Renders the SAIFMenuTop category-link row and CRUD/print/help icon toolbar, deriving button state from the current page's menu-authorization item.
status: draft
owner: SAIF documentation team
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Controls.V2.Menu
reference_type: package
operation_id: OP-MENU-002
trigger: ASP.NET page lifecycle (OnInit -> Page_PreLoad -> CreateChildControls/OnPreRender -> RenderControl) when a SAIFMenuTop control is placed on a ViewPageBase-derived page
---

# Render top toolbar menu

This operation renders the `SAIFMenuTop` top toolbar — a row of category-scoped navigation links plus a group of CRUD/print/help/preference action icons — deriving default button visibility, enabled state, and tooltips from the current page's menu-authorization metadata.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-MENU-002 |
| **Trigger** | ASP.NET page lifecycle events (`OnInit`, `Page_PreLoad`, `CreateChildControls`, `OnPreRender`, `RenderControl`) fired when a `SAIFMenuTop` control instance is present on a `ViewPageBase`-derived page |
| **Inputs** | Session-cached `NavigationContext`, `SelectedCategory`, per-button `clsMenuButton` state in `ViewState`, current page's `clsMenuAuthorizedItem` (`CurrentPage`), browser capabilities (Firefox detection for access-key prefix) |
| **Outputs** | Rendered category link row, icon toolbar (Insert/Save/Delete/Edit/Cancel/Submit/Print/Preview/Email/Download/Calculate/Help/Prefs); `MenuNavigate`, `ToolbarClick`, `DefaultOnSubmit` events |
| **Primary components** | `SAIFMenuTop.OnInit`, `SAIFMenuTop.Page_PreLoad`, `SAIFMenuTop.CreateChildControls`, `SAIFMenuTop.OnPreRender`, `SAIFMenuTop.RenderControl`, `SAIFMenuTop.LinkButtonClick`, `SAIFMenuTop.NavigateToItem`, `SAIFMenuTop.MenuImage_Click`, `SAIFMenuTop.GetGrids` |
| **Entry point** | `SAIF.Presentation.Web.Controls.V2.Menu\SAIFMenuTop.vb` |

## Steps

1. `OnInit` resolves `m_Page` as `ViewPageBase` ([SAIF.Presentation.Web.MVC](../../saif-presentation-web-mvc/overview.md)).
2. `Page_PreLoad` (event) on first load:
   - If `CurrentPage` is not yet cached, retrieves it via `NavigationData.GetCurrentPage()`.
   - When found and not a postback: sets each relevant button's `Visible`/`Enabled` from the current page's `IsDisplayInsert`/`IsDisplaySave`/`IsDisplayDelete`/`IsDisplayPrint`/`IsDisplayDownload`/`IsDisplaySavePreferences`/`IsDisplayHelp` flags (sourced from `clsMenuAuthorizedItem`, external to this library), and copies per-page tooltip text (`PrintToolTip`, `InsertToolTip`, etc.).
   - Calls `BuildClientOneClickJavascript()` to register the one-click-guard script/flag once per page.
3. `CreateChildControls`:
   - Builds the top-of-page category link collection (`BuildLinkCollection`, sorted by `MenuOrder`, filtered to `AppItemsByCategory(SelectedCategory)` and `Item.IsVisible`).
   - Builds the full icon toolbar (`BuildMenuIcons`), creating one `SAIFImageButton` per action (default-submit, help, set/clear-prefs, insert, save, submit, edit, delete, cancel, print, preview, email, download, calculate), each registered in `m_MenuButtons` keyed by control ID and wired to a shared `MenuImage_Click` handler.
   - Scans the page control tree via `GetGrids` for any control whose type name contains `"ULTRAWEBGRID"`.
     - If any are found: registers a page-level `EndEdits()` JavaScript function and wires every toolbar button's `onclick` (except the hidden default-submit button) to call it before postback, ensuring an open Infragistics grid cell edit is committed prior to a toolbar action.
4. `OnPreRender` — for each rendered `SAIFImageButton`:
   - Looks up its `clsMenuButton` state and synchronizes `ImageUrl`, `AccessKey`, and `ToolTip` (prefixing the access-key hint, e.g. `"Alt+I to Insert"`, or `"Shift+Alt+I to Insert"` on Firefox >= v2) from the button model.
   - If `EnableButtonIndicators` is false and the button is flagged `OneClick`: attaches a `mnuOneClickOnly(this)` client-side guard to the `onclick`.
5. `RenderControl`:
   - Renders the navigation `Panel`.
   - If any toolbar button group is visible, renders the toolbar: right-icon group (Help, Set/Clear-Preferences) always inside a `<span class="righticons">`; Insert/Save/Delete/Edit/Cancel/Submit group (with a "pipe" separator image) shown only if `ShowInsertSaveDelete`; Print/Preview/Email/Download/Calculate group shown only if `ShowPrintDownload`.
   - Each individual button renders only if its model's `Visible` is true, and is disabled visually (`DisableIcon`, swapping the image filename to a `_d` "disabled" variant and setting `Enabled = False`) if its model's `Enabled` is false.
   - On failure: wrapped in `Try/Catch` that writes exception details directly to the output writer*.
6. User interaction — clicking a category/page link (`LinkButtonClick`):
   - Raises `MenuNavigate("", "Help")` directly for the literal `"mnuHelp"` control ID.
   - Otherwise parses the item sequence and calls `NavigateToItem`, which looks up the sibling `SAIFMenu1` control on the page (if present) to snapshot its `ContextValue` into `Session("CVTextBox" & ViewID)`, then raises `MenuNavigate(ApplicationPath, PageLink)`.
7. User interaction — clicking any toolbar icon (`MenuImage_Click`):
   - Raises the corresponding `ToolbarClick(ToolBarButton)` event (e.g., `Insert`, `Save`, `Delete`, `Edit`, `Cancel`, `Submit`, `Print`, `Preview`, `Email`, `Download`, `Calculate`, `Help`, `PrefsSet`, `PrefsClear`) for the host page to handle.
   - No business rule, SQL, or table reference is enforced or touched directly in this control — button visibility/enablement is driven entirely by flags sourced from the external `clsMenuAuthorizedItem` object**.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Page lifecycle: OnInit]) --> PreLoad[Page_PreLoad: resolve CurrentPage, apply button Visible/Enabled from clsMenuAuthorizedItem]
	PreLoad --> Create[CreateChildControls: build category links and icon toolbar]
	Create --> GridScan{UltraWebGrid found on page?}
	GridScan -->|Yes| WireEndEdits[Wire onclick handlers to call EndEdits before postback]
	GridScan -->|No| PreRender
	WireEndEdits --> PreRender[OnPreRender: sync ImageUrl/AccessKey/ToolTip per button model]
	PreRender --> Render[RenderControl: render category row and icon groups]
	Render --> D{User interaction?}
	D -->|Click category/page link| Nav[NavigateToItem: snapshot SAIFMenu1 context, raise MenuNavigate]
	D -->|Click toolbar icon| Toolbar[MenuImage_Click: raise ToolbarClick event]
	D -->|No interaction| EndOk([Render complete])
```

## Failure and edge-case behavior
- `RenderControl` exceptions are caught and written directly into the HTML output stream (message/source/stack trace) rather than logged or suppressed, a potential information-disclosure risk in production*.
- Toolbar button groups (Insert/Save/Delete/Edit/Cancel/Submit and Print/Preview/Email/Download/Calculate) render only when their respective `ShowInsertSaveDelete`/`ShowPrintDownload` flags are true; otherwise the entire group is omitted.
- A disabled button (`Enabled = False` on its `clsMenuButton` model) is rendered with a `_d` "disabled" image variant rather than being hidden.
- **UI behavior note — disabled icon rendering:** `DisableIcon` swaps in the `_d` disabled image variant and sets `Enabled = False` on the rendered `SAIFImageButton` instead of hiding the icon, preserving toolbar layout; this is a presentational default, not a business rule.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [API reference](../api/index.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.V2.Menu\SAIFMenuTop.vb`
