Skip to content

Multi-line character counter

Add an optional live character counter to multi-line, length-limited textboxes. Init, CreateChildControls, and RenderControl for a SAIFTextBox instance.

Field Value
Operation ID OP-V2-017
Trigger Init, CreateChildControls, and RenderControl for a SAIFTextBox instance.
Inputs TextMode, MaxLength, ShowCharacterCounter, Visible.
Outputs The base textbox, optionally followed by a character-counter panel and a SaifMaxLength attribute.
Primary components SAIFTextBox
Entry point SAIF.Presentation.Web.Controls.V2/SAIFTextBox.vb

Steps

  1. On Init, register /Resources/Scripts/Controls/TextBox.js unless already registered. (BR-V2-095)
  2. On CreateChildControls, when TextMode is MultiLine, MaxLength is greater than zero and ShowCharacterCounter is true, add a Panel with ID msg and CSS class saiftextlimitmsg sized to the textbox width. (BR-V2-096)
  3. On RenderControl, when invisible render nothing; when multi-line with a maximum length, emit the SaifMaxLength attribute, render the base textbox, then render the counter panel if the counter is enabled; otherwise render the base textbox only. (BR-V2-097, BR-V2-098, BR-V2-099)

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Init]) --> Script[Register TextBox.js]
    Script --> CCC[CreateChildControls]
    CCC --> Cond{MultiLine, MaxLength>0, ShowCharacterCounter?}
    Cond -->|Yes| Counter[Add msg counter panel]
    Cond -->|No| Skip[No counter panel]
    Counter --> Render([RenderControl]) 
    Skip --> Render
    Render --> Vis{Visible?}
    Vis -->|No| NoOut([No output])
    Vis -->|Yes| Emit[Emit SaifMaxLength, render base textbox + counter]

Failure and edge-case behavior

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

Sources

  • SAIF.Presentation.Web.Controls.V2/SAIFTextBox.vb