Edit this page

OnClientCheckedChanging

The checkedChanging event is subsequent to the clicking event, and occurs before the RadCheckBox checked state is changed.

The event handler receives two parameters:

  1. The instance of the clicked RadCheckBox control.

  2. 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 RadCheckBox's CommandName property.

    • get_commandArgument() - returns the value assigned to the RadCheckBox'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 checkbox 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.

Example 1: Using OnClientCheckedChanging event.

<script type="text/javascript">
    function CheckedChanging(sender, args) {
        args.set_cancel(!window.confirm("Are you sure you want to change the checked state of the checkbox?"));
    }
</script>

<telerik:RadCheckBox ID="RadCheckBox1" runat="server"
    OnClientCheckedChanging="CheckedChanging">
</telerik:RadCheckBox>

See Also