AutoComplete HtmlHelper Overview

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

The AutoComplete provides suggestions depending on the typed text and allows multiple value entries.

Basic Configuration

This runnable demo demonstrates how to define an AutoComplete by using the AutoComplete HtmlHelper.

Functionality and Features

Events

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

Handling by Handler Name

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

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

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

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

Handling by Template Delegate

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

    @(Html.Kendo().AutoComplete()
        .Name("autocomplete")
        .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 AutoComplete instance, use the jQuery.data() configuration option. Once a reference is established, use the AutoComplete client-side API to control its behavior.

// Place this after the AutoComplete for ASP.NET MVC declaration.
<script>
    $(function() {
        // The Name() of the AutoComplete is used to get its client-side instance.
        var autocomplete = $("#productAutoComplete").data("kendoAutoComplete");
    });
</script>

See Also

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