How to subscribe ValueChange event to Switch?

Hi team,

Please check the attached project. It could not be compiled. I suspect the official document is too old to follow the version upgrade. Please tell me how to get informed when the Switch component being check and unchecked?

Thanks.

Attachment: SyncfusionBlazorSwitch_a610c4e6.rar

3 Replies 1 reply marked as answer

MK Mohan Kumar Ramasamy Syncfusion Team September 1, 2020 06:50 AM UTC

Hi Brian, 
 
We have provided the generic type support for Checked property. And also we have changed event arguments as strongly type for ChangeEventArgs. Could you please find the below code snippet. 
 
            <label style="padding: 10px 70px 10px 0;" >USB Tethering</label> 
            <SfSwitch @bind-Checked="@isUSB" ValueChange="OnUSBChange" TChecked="bool"></SfSwitch> 
            </div> 
            <div> 
            <label style="padding: 10px 24px 10px 0; ">Portable Wi-Fi hotspot</label> 
            <SfSwitch @bind-Checked="@ishotspot" ValueChange="OnHotspotChange" TChecked="bool"></SfSwitch> 
            </div> 
            <div> 
            <label style="padding: 10px 40px 10px 0; ">Bluetooth Tethering</label> 
            <SfSwitch Disabled="true" @bind-Checked="@isBluetooth"></SfSwitch> 
<br/> 
@code { 
    private bool isUSB = true; 
    private bool ishotspot = false; 
    private bool isBluetooth = false; 
 
 
    private void OnUSBChange(Syncfusion.Blazor.Buttons.ChangeEventArgs<bool> obj) 
    { 
         
    } 
     
    private void OnHotspotChange(Syncfusion.Blazor.Buttons.ChangeEventArgs<bool> obj) 
    { 
         
    } 
}| 
 
 
  
 
Please let us know, if you need any further assistance, 
 
Regards, 
Mohankumar R 
 


Marked as answer

BR Brian September 1, 2020 12:13 PM UTC

It works, Thanks.


MK Mohan Kumar Ramasamy Syncfusion Team September 2, 2020 08:46 AM UTC

Hi Brian,   
  
Thanks for the update.  
 
We are happy to hear that your issue has been resolved. Please feel free to contact us if you need any further assistance on this. 
 
Regards, 
Mohankumar R 
 


Loader.
Up arrow icon