New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

OnClientDropDownOpening

The OnClientDropDownOpening client-side event occurs before the drop-down list opens.

The event handler receives two parameters:

  1. The instance of the DropDownList firing the event.

  2. An eventArgs parameter containing the following methods:

    • set_cancel lets you prevent the drop-down from opening.

The example below shows how to prevent the drop-down list from opening when there are no items to be displayed:

<script language="javascript" type="text/javascript">
    function OnClientDropDownOpening(sender, eventArgs) {
        if (sender.get_items().get_count() == 0)
            eventArgs.set_cancel(true);
    }
</script>
<telerik:RadDropDownList
    ID="RadDropDownList1"
    runat="server"
    OnClientDropDownOpening="OnClientDropDownOpening">
</telerik:RadDropDownList>
In this article