---
title: Collapsible panel state toggle
summary: Persists and renders the expand/collapse state of a SAIFPanel across postbacks.
status: draft
owner: SAIF Documentation Team
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Controls.V2
reference_type: package
operation_id: OP-V2-PANEL-001
trigger: Postback containing the hidden StateControl field value
---

# Collapsible panel state toggle

This operation manages the expand/collapse state of a `SAIFPanel`, persisting it through a hidden field so it survives postbacks, and applying the corresponding inline display style and image on each render pass.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-V2-PANEL-001 |
| **Trigger** | Postback containing the hidden `StateControl` field value (`"Collapsed"`/other). |
| **Inputs** | `HttpContext.Current.Request(Me.UniqueID & "$StateControl")`. |
| **Outputs** | Header/Title/collapse-expand image/hidden state field/Content panel control tree with correct `display` style and image URL. |
| **Primary components** | `SAIFPanel.SAIFPanel_Init`, `SAIFPanel.CreateChildControls`, `SAIFPanel.SAIFPanel_PreRender`. |
| **Entry point** | `SAIF.Presentation.Web.Controls.V2\SAIFPanel.vb` |

## Steps

1. `SAIFPanel_Init` reads `HttpContext.Current.Request(Me.UniqueID & "$StateControl")`; if present and non-empty, sets `_PanelState` accordingly.
2. `CreateChildControls` builds the Header/Title/collapse-expand image/hidden state field/Content panel tree, using `_PanelState` to decide the initial `display: none;`/`display: block;` inline style and expand/collapse image URL.
3. `PreRender` re-syncs the collapse/expand image and hidden field to the current `_PanelState`.

- No server-side business logic determines panel state beyond what the client posts back — actual expand/collapse toggling is client-script driven (the referenced `Panel.js` script file is not included in this project)*.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Postback]) --> Init[SAIFPanel_Init reads StateControl field]
	Init --> Decision{State value present?}
	Decision -->|Yes| Set[Set _PanelState from posted value]
	Decision -->|No| Keep[Keep existing _PanelState]
	Set --> Create[CreateChildControls builds tree with matching display style]
	Keep --> Create
	Create --> PreRender[PreRender re-syncs image and hidden field]
	PreRender --> Done([Rendered panel HTML])
```

## Failure and edge-case behavior

- An unrecognized or missing `StateControl` value leaves `_PanelState` at its prior/default value (`Expanded`) rather than raising an error.
- The client-side `Panel.js` script that performs the actual collapse/expand animation is not present in this project folder; its exact behavior could not be verified from this library's source**.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.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\SAIFPanel.vb
