---
title: Manage tabs
summary: Add, select, style, sort, and persist a collection of navigation tabs.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Controls.V2
reference_type: package
operation_id: OP-V2-011
trigger: Host page calls `AddTab`/`InsertTab`; `CreateChildControls` for `SAIFTabBar`; postback for view-state persistence.
---

# Manage tabs

Add, select, style, sort, and persist a collection of navigation tabs. Host page calls `AddTab`/`InsertTab`; `CreateChildControls` for `SAIFTabBar`; postback for view-state persistence.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-V2-011 |
| **Trigger** | Host page calls `AddTab`/`InsertTab`; `CreateChildControls` for `SAIFTabBar`; postback for view-state persistence. |
| **Inputs** | Tab text, client ID, div ID, selected/enabled/visible flags, access key, width, `Mode`. |
| **Outputs** | An ordered tab collection, rendered tab links/bar, and selection change events. |
| **Primary components** | `SAIFTabs / SAIFTabBar` |
| **Entry point** | `SAIF.Presentation.Web.Controls.V2/SAIFTabs.vb` |

## Steps

1. `SAIFTabs.AddTab` / `InsertTab` create a `TabSettings` entry (text, client ID, div ID, selected, access key, width, visible, index) and append or insert it into the tab list. ([BR-V2-066](../business-rules.md#br-v2-066-tabs-identified-by-client-id-and-content-div-id), [BR-V2-067](../business-rules.md#br-v2-067-tab-index-assigned-from-current-tab-count))
2. When the added tab is selected, capture the prior selected tab and raise `SelectedIndexChanged` with a `SAIFTabEventArgs` carrying both tabs. ([BR-V2-068](../business-rules.md#br-v2-068-adding-a-selected-tab-raises-selectedindexchanged))
3. `SelectedTab` returns the first tab whose `Selected` flag is set, or a new empty `TabSettings` when none is selected; `SelectedTabId`, `SelectedTabIndex` and `SelectedTabText` are derived from it. ([BR-V2-069](../business-rules.md#br-v2-069-selected-tab-is-the-first-tab-with-selected-set), [BR-V2-070](../business-rules.md#br-v2-070-no-selection-returns-an-empty-tabsettings-not-nothing))
4. `SAIFTabs.IsDesign` returns `True` when reading `Page.User` throws, which is used to suppress run-time-only behaviour in the designer. ([BR-V2-071](../business-rules.md#br-v2-071-design-mode-detected-by-pageuser-throwing))
5. `SAIFTabBar.CreateChildControls` creates one `LinkButton` per tab and assigns CSS classes `Selected`, `SelectedSibling`, `Disabled` or `DisabledSelected` according to tab state and position; the bar itself is styled `SAIFTabBar` or `SAIFWizardTabBar` depending on `Mode`. ([BR-V2-072](../business-rules.md#br-v2-072-tab-bar-styling-differs-by-mode), [BR-V2-073](../business-rules.md#br-v2-073-tab-after-the-selected-tab-is-styled-selectedsibling), [BR-V2-074](../business-rules.md#br-v2-074-disabled-tabs-render-without-postback))
6. `SAIFTabBar` persists its tab collection through `SaveViewState`/`LoadViewState`, and exposes `EnableAllTabs`, `DisableAllTabs`, `ShowAllTabs`, `HideAllTabs` and `Tabs.GetTabByID` for bulk state changes. ([BR-V2-075](../business-rules.md#br-v2-075-tab-state-persisted-through-custom-view-state-methods), [BR-V2-076](../business-rules.md#br-v2-076-bulk-tab-state-operations-exposed))
7. `SAIFTabBarTabCollection.Sort` uses the reflection-based `Sorter(Of T)` comparer to order tabs by a named property. ([BR-V2-077](../business-rules.md#br-v2-077-tabs-sortable-by-any-named-property))

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([AddTab/InsertTab]) --> Create[Create TabSettings entry]
	Create --> Sel{Tab selected?}
	Sel -->|Yes| Event[Raise SelectedIndexChanged]
	Sel -->|No| Bar
	Event --> Bar[SAIFTabBar.CreateChildControls]
	Bar --> Style[Assign per-tab CSS classes]
	Style --> Persist[Persist via SaveViewState/LoadViewState]
	Persist --> Done([Tabs rendered])
```

## Failure and edge-case behavior

- No exceptional failure handling beyond the branches described in **Steps** was found in the analysis findings.*

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

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