|
@using Syncfusion.Blazor.Buttons
<SfSwitch ValueChange="OnChangeButton" Checked="false">SfSwitch>
@code{
public void OnChangeButton(Syncfusion.Blazor.Buttons.ChangeEventArgs e)
{
if(e.Checked == true)
{
Console.WriteLine("true");
}
}
} |
|
@using Syncfusion.Blazor.Buttons
@using System.ComponentModel.DataAnnotations
@foreach (ModuleOptionDto option in module)
{
<SfSwitch ValueChange="@((Syncfusion.Blazor.Buttons.ChangeEventArgs e) => OnChangeButton(e, option))" ID="@option.Id" Checked="false"></SfSwitch>
}
@code{
public void OnChangeButton(Syncfusion.Blazor.Buttons.ChangeEventArgs e, ModuleOptionDto option)
{
// Here, e.checked is always false
}
List<ModuleOptionDto> module = new List<ModuleOptionDto> {
new ModuleOptionDto { Id="a1", Name="Switch1" },
new ModuleOptionDto { Id="a2", Name="Switch1" }
};
public class ModuleOptionDto
{
public string Id { get; set; }
public string Name { get; set; }
}
} |