Restore focus and handle errors after an async refresh¶
This operation wires SAIFWarp's focus-restoration and error-notification behavior into the ASP.NET WebForms control lifecycle, and defines the client-side handlers that run after the underlying WebAsyncRefreshPanel completes an asynchronous refresh.
| Field | Value |
|---|---|
| Operation ID | OP-03 |
| Trigger | ASP.NET control lifecycle events Init, PreRender, CreateChildControls, RenderContents on the consuming page |
| Inputs | ControlsFocus, FocusControlID, DesignMode |
| Outputs | Hidden field <ID>_FOCUS; registered client scripts WARP_FOCUS_CONTROL, WARP_Init, SAIFWarp_Error; assigned ClientSideEvents handlers |
| Primary components | SAIFWarp |
| Entry point | SAIF.Presentation.Web.Controls.Infragistics111/SAIFWarp.vb |
Steps¶
- On
Init, exit immediately whenDesignModeis true so the designer surface is unaffected (BR-CTL-007). - Still on
Init, whenControlsFocusis true and theWARP_FOCUS_CONTROLblock is not already registered, registerFOCUS_SCRIPTand setClientSideEvents.RefreshComplete = "SAIFWARP_RefreshComplete"(BR-CTL-008). - If
WARP_FOCUS_CONTROLis already registered on the page: registration and theRefreshCompleteassignment are both skipped for this instance. - Still on
Init, inside theControlsFocusbranch, setClientSideEvents.InitializePanel = INIT_SCRIPT_NAME. - Note: this assignment sits inside the
ControlsFocusblock, so the progress-indicator initializer is wired only when focus handling is enabled, even though the init script itself is registered unconditionally inPreRender.* - In
CreateChildControls, call the base implementation, create anHtmlInputHiddenwith ID<ID>_FOCUS, seed its value fromFocusControlID, and add it toControls(BR-CTL-009). - On
PreRender(skipped in design mode), setClientSideEvents.Error = "SAIFWarp_Error"; register the error startup script built fromDEFAULT_ERRORif not already registered; register theWARP_Initprogress-indicator script if not already registered (BR-CTL-008, BR-CTL-010). - In
RenderContents, re-copyFocusControlIDinto the hidden field value before delegating to the base renderer, so a value assigned afterCreateChildControlsstill reaches the client (BR-CTL-009). - In the browser,
SAIFWARP_RefreshCompletereads the hidden field, resolves the named control, and callsfocus()three times inside atry/catch; it then calls the optional page-suppliedAdditionRefreshComplete(oPanel)hook inside a secondtry/catch(BR-CTL-011). - On failure: focus errors are swallowed by the first
try/catch; errors from the optional hook are swallowed by the second, independenttry/catch. - In the browser,
SAIFWarp_Error(oPanel,oEvent,flags)navigates to/weberror/processError.aspx?MSG=<message>whenflags > 1(BR-CTL-010). - If
flags <= 1: the failure is ignored silently and no redirect occurs.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Page lifecycle begins]) --> Init{"Init: DesignMode?"}
Init -->|Yes| EndDesign(["No script wiring"])
Init -->|No| S2["Register WARP_FOCUS_CONTROL<br>if not registered"]
S2 --> S3["CreateChildControls:<br>add hidden _FOCUS field"]
S3 --> S4["PreRender: wire Error handler,<br>register error + init scripts"]
S4 --> S5["RenderContents:<br>refresh hidden field value"]
S5 --> Client["Browser: async refresh completes"]
Client --> D{"Callback flags > 1?"}
D -->|Yes| Redirect(["Navigate to<br>/weberror/processError.aspx"])
D -->|No| Focus["SAIFWARP_RefreshComplete<br>restores focus"]
Failure and edge-case behavior¶
- Focus-restoration failures in the browser are caught and swallowed so the page remains usable (BR-CTL-011).
- The optional
AdditionRefreshCompletehook's own errors are caught independently and do not prevent focus restoration from having already run. - Asynchronous errors with
flags <= 1are ignored silently; onlyflags > 1triggers the redirect to the central error page. SAIFWarp's error script always carries the constantDEFAULT_ERRORmessage; no code path in this library supplies a specific exception message throughGetScriptWithMessage.**
Related documentation¶
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.Infragistics111/SAIFWarp.vb