The checkedChanging event is subsequent to the clicking event, and occurs before the RadSwitch checked state is changed.
The event handler receives two parameters:
The instance of the clicked RadSwitch control.
An eventArgs parameter of type Telerik.Web.UI.ButtonCheckedCancelEventArgs, containing the following properties and methods:
get_cancel() - returns a bool value that indicates whether the event was canceled. True means the event is canceled.
set_cancel(shouldCancel) - sets a bool value that indicates whether the event will be canceled. Setting true means the event will be canceled.
get_checked() - returns the checked state of the control.
get_domEvent() - returns the DOM event of the control.
get_commandName() - returns the value assigned to the RadSwitch's CommandName property.
get_commandArgument() - returns the value assigned to the RadSwitch's CommandArgument property.
This event is useful in scenarios where the user wants to make sure the checked state is changed only if a certain condition is met. Note that, if the switch automatically posts back to the server, which is the default behavior, the post back will not be stopped even if the event is canceled.
The following example asks the user to confirm whether they want to change the state.