alexa
menu

Blazor Toolkit

    Show / Hide Table of Contents

    Class SfSelectionBase<TChecked>

    Provides a base class for form _input components in Syncfusion Blazor, encapsulating common functionality and API contracts for _input controls with checked/value states.

    Inheritance
    System.Object
    SfBaseComponent
    SfSelectionBase<TChecked>
    SfCheckBox<TChecked>
    SfRadioButton<TChecked>
    SfSwitch<TChecked>
    Implements
    System.IAsyncDisposable
    Inherited Members
    SfBaseComponent.DisposeAsync()
    Namespace: Syncfusion.Blazor.Toolkit.Inputs
    Assembly: Syncfusion.Blazor.Toolkit.dll
    Syntax
    public abstract class SfSelectionBase<TChecked> : SfBaseComponent, IAsyncDisposable
    Type Parameters
    Name Description
    TChecked

    The type of the checked value (typically System.Boolean for checkboxes or System.String for radio buttons).

    Remarks

    This abstract class defines core implementation for form-oriented _input elements—such as checkboxes and radio buttons—offering consistent property contracts for Checked/Value/CssClass/Name, support for form integration, RTL rendering, persistence, and extensible rendering. Component developers should inherit this base to ensure seamless interop, accessibility, and persistence with Syncfusion’s form controls.

    Examples

    See SfCheckBox or SfRadioButton for real-world usage and parameter pattern derived from SfSelectionBase<TChecked>.

    Constructors

    SfSelectionBase()

    Declaration
    protected SfSelectionBase()

    Properties

    Checked

    Gets or sets the checked state of the component.

    Declaration
    public TChecked Checked { get; set; }
    Property Value
    Type Description
    TChecked

    A value of type TChecked (typically System.Boolean for checkboxes or System.String for radio buttons).

    Remarks

    This Checked property controls the selection state of the component and determines whether it is rendered as checked or selected. Changing this value updates the visual state and can trigger two-way binding updates.

    Examples
    <SfCheckBox @bind-Checked="isAccepted" />
    <SfRadioButton TValue="string" @bind-Checked="selectedOption" Value="option1" />

    Created

    Gets or sets an event callback that is invoked when the component has been initialized and rendered.

    Declaration
    public EventCallback<object> Created { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    An Microsoft.AspNetCore.Components.EventCallback<> that is triggered after the component's first render.

    Remarks

    Use this event to perform custom initialization logic or to access the component after it has been fully created and rendered in the DOM.

    Examples
    <SfCheckBox Created="@OnCheckBoxCreated" Label="Accept Terms" />
    
    @code {
        private void OnCheckBoxCreated(object args)
        {
            // Perform post-initialization tasks
            Console.WriteLine("CheckBox created successfully");
        }
    }

    CssClass

    Gets or sets the CSS class name(s) to customize the visual appearance of the component.

    Declaration
    public string CssClass { get; set; }
    Property Value
    Type Description
    System.String

    A space-separated string of CSS class names. The default value is System.String.Empty.

    Remarks

    Use CssClass property to apply custom styling, themes, or branding to the component. Multiple classes can be specified by separating them with spaces.

    Examples
    <SfCheckBox CssClass="custom-checkbox primary-theme" />

    Disabled

    Gets or sets a value indicating whether the component is disabled.

    Declaration
    public bool Disabled { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the component is disabled; otherwise, false. The default value is false.

    Remarks

    When Disabled is true, the component is non-interactive and cannot receive user _input. The component will also display visual styling indicating its disabled state.

    Examples
    <SfRadioButton Disabled="true" Label="Unavailable Option" />

    EnablePersistence

    Gets or sets a value indicating whether to persist the component's state across browser sessions.

    Declaration
    public bool EnablePersistence { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to enable state persistence; otherwise, false. The default value is false.

    Remarks

    When EnablePersistence is true, the component's checked state is saved to the browser's localStorage and automatically restored when the page is reloaded. This provides a better user experience by maintaining the component's state across sessions.

    Examples
    <SfCheckBox EnablePersistence="true" Label="Remember my choice" />

    HasOnChangeEvent

    Indicates whether the component has a native onchange event handler attached via HTML attributes.

    Declaration
    protected bool HasOnChangeEvent { get; set; }
    Property Value
    Type
    System.Boolean

    Name

    Gets or sets the name attribute of the _input element for form submission.

    Declaration
    public string Name { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the _input's name. The default value is System.String.Empty.

    Remarks

    The Name property identifies the component's value when a form is submitted. It is essential for proper form integration and server-side model binding.

    Examples
    <SfRadioButton Name="gender" Value="male" />

    Value

    Gets or sets the value to be submitted with the form data.

    Declaration
    public string Value { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the _input value. The default value is null.

    Remarks

    The Value property specifies the value that will be sent to the server when the form is submitted. For radio buttons, this typically represents the unique value for each option in a group.

    Examples
    <SfCheckBox Value="subscribe" Name="newsletter" />

    Methods

    InitRender(Boolean)

    Called by derived classes to initialize the visual state. Override to compute classes.

    Declaration
    protected virtual void InitRender(bool isDynamic = false)
    Parameters
    Type Name Description
    System.Boolean isDynamic

    True when the checked value changed dynamically.

    OnAfterRenderAsync(Boolean)

    Executes after the first render to restore persisted state and raise the Created event.

    Declaration
    protected override Task OnAfterRenderAsync(bool firstRender)
    Parameters
    Type Name Description
    System.Boolean firstRender

    Indicates whether this is the first render of the component.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation.

    Overrides
    Syncfusion.Blazor.Toolkit.SfBaseComponent.OnAfterRenderAsync(System.Boolean)

    OnInitializedAsync()

    Initializes the component state when the component is first created.

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation.

    Overrides
    Syncfusion.Blazor.Toolkit.SfBaseComponent.OnInitializedAsync()

    OnParametersSetAsync()

    Handles parameter updates, detects checked state changes, and recomputes visual state.

    Declaration
    protected override Task OnParametersSetAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation.

    SetLocalStorageAsync(String, TChecked)

    Persists the checked state to browser's localStorage.

    Declaration
    protected Task SetLocalStorageAsync(string persistId, TChecked checkedValue)
    Parameters
    Type Name Description
    System.String persistId

    The storage key identifier.

    TChecked checkedValue

    The checked value to persist.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation.

    UpdateCheckStateAsync(TChecked)

    Updates the Checked state through EditContext and notifies two-way binding.

    Declaration
    protected Task UpdateCheckStateAsync(TChecked state)
    Parameters
    Type Name Description
    TChecked state

    The new checked value.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A task representing the asynchronous operation.

    Implements

    System.IAsyncDisposable
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved