ComboBox HtmlHelper Overview

The Telerik UI ComboBox HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI ComboBox widget.

The ComboBox displays a list of values and allows for a single selection from the list.

Basic Configuration

This runnable demo demonstrates how to define a ComboBox by using the ComboBox HtmlHelper.

Functionality and Features

Events

You can subscribe to all ComboBox events. For a complete example on basic ComboBox events, refer to the demo on using the events of the ComboBox.

Handling by Handler Name

The following example demonstrates how to subscribe to events by a handler name.

    <%: Html.Kendo().ComboBox()
        .Name("combobox")
        .BindTo(new string[] { "Item1", "Item2", "Item3" })
        .Events(e => e
            .Select("combobox_select")
            .Change("combobox_change")
        )
    %>
    <script>
    function combobox_select() {
        // Handle the select event.
    }

    function combobox_change() {
        // Handle the change event.
    }
    </script>
    @(Html.Kendo().ComboBox()
        .Name("combobox")
        .BindTo(new string[] { "Item1", "Item2", "Item3" })
        .Events(e => e
            .Select("combobox_select")
            .Change("combobox_change")
        )
    )
    <script>
        function combobox_select() {
            // Handle the select event.
        }

        function combobox_change() {
            // Handle the change event.
        }
    </script>

By Template Delegate

The following example demonstrates how to subscribe to events by a template delegate.

    @(Html.Kendo().ComboBox()
        .Name("combobox")
        .BindTo(new string[] { "Item1", "Item2", "Item3" })
        .Events(e => e
            .Select(@<text>
                function() {
                    // Handle the select event inline.
                }
            </text>)
            .Change(@<text>
                function() {
                    // Handle the change event inline.
                }
            </text>)
        )
    )

Referencing Existing Instances

To reference an existing ComboBox instance, use the jQuery.data() configuration option. Once a reference is established, use the ComboBox client-side API to control its behavior.

// Place the following after the ComboBox for ASP.NET MVC declaration.
<script>
    $(function() {
        // The Name() of the ComboBox is used to get its client-side instance.
        var combobox = $("#productComboBox").data("kendoComboBox");
    });
</script>

See Also

In this article
Not finding the help you need? Improve this article