---
title: Focus-control script generation
summary: Generates client-side JavaScript that sets input focus on a target control when a master page renders.
status: draft
owner: SAIF Documentation Team
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Core.Infragistics103
reference_type: package
operation_id: OP-AVMPB-001
trigger: Page_PreRender on any master page inheriting AppViewMasterPageBase
---

# Focus-control script generation

This operation generates and registers client-side JavaScript that focuses (and, for text-input types, selects) a target control on the page, driven by the `FocusControl` property set by the page/consuming code.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-AVMPB-001 |
| **Trigger** | `Page_PreRender` on any master page inheriting `AppViewMasterPageBase` |
| **Inputs** | `FocusControl` property (set by the page/consuming code) |
| **Outputs** | A registered startup script that focuses (and optionally selects) the target control |
| **Primary components** | `AppViewMasterPageBase.RenderClientScripts`, `RegisterFocusControlScript`, nested `NavigationManager` class |
| **Entry point** | `SAIF.Presentation.Web.Core.Infragistics103\AppViewMasterPageBase.vb` |

## Steps

1. `Page_PreRender` calls `RenderClientScripts`.
2. `RenderClientScripts`: if `FocusControl` is not `Nothing`, calls `RegisterFocusControlScript`.
3. `RegisterFocusControlScript` branches on the runtime type name of `FocusControl` to build a jQuery/JS snippet that focuses (and for text-input types, selects) the client-rendered element, wrapped in a 100ms `setTimeout` and a `try/catch`:
   - `Infragistics.WebUI.WebDataInput` → focus and select via jQuery `#igtxt<ClientID>`.
   - `Infragistics.WebUI.WebCombo` → focus and select via jQuery on the combo's input element.
   - `Infragistics.WebUI.WebSchedule.WebDateChooser` → focus and select via jQuery on the date chooser's input element.
   - `System.Web.UI.WebControls.Button` → focus only, via jQuery.
   - `Infragistics.Web.UI.ListControls` → no script generated (empty branch)*.
   - Any other type → focus and select via jQuery on the control's `ClientID`.
4. The script is registered via `UI.ScriptManager.RegisterStartupScript`.
5. The nested `NavigationManager` class provides an alternate, session-persisted (`Session("focuscontrol")`) mechanism*:
   - `BoundControlId` setter classifies a control into one of several Infragistics control-type buckets (or falls back to `ClientID`).
   - `GenerateScripts()` emits the type-appropriate Infragistics API call (`igdrp_getComboById`, `igcmbo_getComboById`, `igedit_getById`, or a plain jQuery focus/select) — this appears to be an older/parallel focus mechanism to `RegisterFocusControlScript`*.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Page_PreRender]) --> S1[RenderClientScripts]
	S1 --> D1{FocusControl set?}
	D1 -->|No| EndNone([No script registered])
	D1 -->|Yes| S2[RegisterFocusControlScript]
	S2 --> S3{Control runtime type?}
	S3 -->|WebDataInput| S4a[Focus and select via jQuery]
	S3 -->|WebCombo| S4b[Focus and select combo input]
	S3 -->|WebDateChooser| S4c[Focus and select date input]
	S3 -->|Button| S4d[Focus only]
	S3 -->|ListControls| S4e[No script - empty branch]
	S3 -->|Other| S4f[Focus and select via jQuery ClientID]
	S4a --> S5[RegisterStartupScript]
	S4b --> S5
	S4c --> S5
	S4d --> S5
	S4e --> S5
	S4f --> S5
	S5 --> EndOk([Script registered])
```

## Failure and edge-case behavior
- The generated script is wrapped in a `try/catch` on the client side, so a JavaScript error focusing the control is silently swallowed in the browser.
- The `Infragistics.Web.UI.ListControls` branch generates no focus script, leaving the base string with no client action appended*.

## 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.Core.Infragistics103\AppViewMasterPageBase.vb
