Skip to content

Set client-side focus

This operation places client-side keyboard focus on a designated control after page load, adapting the JavaScript selector to the control's runtime type because Infragistics editors render nested input elements rather than a single focusable DOM node.

Field Value
Operation ID OP-CORE-010
Trigger Master page PreRender, or explicit use of NavigationManager
Inputs FocusControl property; Session("focuscontrol")
Outputs Registered startup script that focuses (and optionally selects) the target control
Primary components AppViewMasterPageBase.RenderClientScripts, AppViewMasterPageBase.RegisterFocusControlScript, AppViewMasterPageBase.NavigationManager
Entry point SAIF.Presentation.Web.Core.Infragistics111/AppViewMasterPageBase.vb

Steps

  1. On PreRender, check whether FocusControl is set.
  2. If FocusControl is Nothing: exit immediately with no script registered. (BR-CORE-028)
  3. Branch on the control's runtime type name to pick the correct client-side selector: (BR-CORE-029)
  4. Infragistics WebDataInput: use the #igtxt<ClientID> element.
  5. WebCombo: use <ClientID with _ → x>_input.
  6. WebSchedule.WebDateChooser: use <ClientID>_input.
  7. Button: focus without selecting.
  8. Infragistics.Web.UI.ListControls: produce no script.
  9. Any other type: fall back to #<ClientID>.
  10. Wrap the selector call in try{setTimeout(function(){…}, 100);}catch(e){} and register it as the FocusControl startup script. (BR-CORE-030)
  11. On failure (element missing from the rendered DOM): the catch(e){} silently absorbs the error; the page continues to render normally.
  12. As an alternative path, NavigationManager provides a session-backed mechanism:
  13. Setting BoundControlId classifies the control, mapping SAIFMENU to the CVTextBox context box. (BR-CORE-031)
  14. The derived ID is stored in Session("focuscontrol").
  15. GenerateScripts emits the matching legacy Infragistics igdrp_ / igcmbo_ / igedit_ focus (and optional select) calls.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Master PreRender]) --> D1{FocusControl set?}
    D1 -->|No| EndNone([No script registered])
    D1 -->|Yes| S1[Determine control type]
    S1 --> S2[Build type-specific client selector]
    S2 --> S3[Wrap in try/setTimeout/catch, register startup script]
    S3 --> EndOk([Focus applied 100ms after load])
    Start2([NavigationManager.BoundControlId set]) --> N1{Control is SAIFMENU?}
    N1 -->|Yes| N2[Redirect to CVTextBox]
    N1 -->|No| N3[Classify control normally]
    N2 --> N4[Store ID in Session focuscontrol]
    N3 --> N4
    N4 --> N5[GenerateScripts emits igdrp_/igcmbo_/igedit_ calls]

Failure and edge-case behavior

  • A missing DOM element at focus time never breaks the page — the client-side catch(e){} absorbs the error silently. (BR-CORE-030)
  • Infragistics.Web.UI.ListControls types produce no focus script at all — focus silently does not occur for those controls.

Sources

  • SAIF.Presentation.Web.Core.Infragistics111/AppViewMasterPageBase.vb