.NET Core Blazor: How to toggle the Checkbox?

In .NET core Blazor you can toggle the checkbox 

1. First declare a boolean variable and initialize the value of the variable, the default 
    value of the boolean variable is false.

2. Bind the checkbox with the variable.

3. Render the variable with @variable_name(IsChecked) in this case we have declared IsActive                  boolean   variable.




    @code{
        public bool IsChecked = true;
    }

    <input type="checkbox" id="toggle" @bind="@IsChecked" > 
    <label for="toggle" id="toggle">Toggle Box</label>
    <h4>@IsChecked</h4>





Reactions

Post a Comment

0 Comments