The toggleStateChanging event is subsequent to the clicking event, and occurs before the RadToggleButton state is changed.
The event handler receives two parameters:
The instance of the clicked RadToggleButton control.
An eventArgs parameter of type Telerik.Web.UI.RadButtonCheckedEventArgs, 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_commandName() - returns the value assigned to the RadToggleButton's CommandName property.
get_commandArgument() - returns the value assigned to the RadToggleButton's CommandArgument property.
This event is useful in scenarios where the user wants to make sure the ToggleState is changed only if a certain condition is met. Note that, if the button automatically posts back to the server, which is the default behavior, the postback 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 of the button.