# ASP.NET MVC AutoComplete 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.

* [Demo page for the AutoComplete HtmlHelper](https://demos.telerik.com/aspnet-mvc/autocomplete/index)

## Initializing the AutoComplete

The following example demonstrates how to define the AutoComplete.

```Razor HtmlHelper
    @(Html.Kendo().AutoComplete()
        .Name("autocomplete")
        .DataTextField("ProductName")
        .Filter("contains")
        .DataSource(source =>
        {
            source.Read(read =>
            {
                read.Action("Products_Read", "AutoComplete")
                    .Data("onAdditionalData");
            })
            .ServerFiltering(true);
        })
    )

    <script type="text/javascript">
        function onAdditionalData() {
            return {
                text: $("#autocomplete").val()
            };
        }
    </script>
```

```C# Controller

    public class AutoCompleteController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public JsonResult Products_Read(string text)
        {
            var result = GetProducts();

            if (!string.IsNullOrEmpty(text))
            {
                result = result.Where(p => p.ProductName.Contains(text)).ToList();
            }

            return Json(result, JsonRequestBehavior.AllowGet);
        }

        private static IEnumerable<ProductViewModel> GetProducts()
        {
            var result = Enumerable.Range(0, 50).Select(i => new ProductViewModel
            {
                ProductID = "" + i,
                ProductName = "Product " + i
            });

            return result;
        }
    }
```

## Basic Configuration

The following example demonstrates the basic configuration of the AutoComplete.

```Razor HtmlHelper
    @(Html.Kendo().AutoComplete()
        .Name("autocomplete")
        .DataTextField("ProductName")
        .Placeholder("Type a product name")
        .Template("#= ProductID # | For: #= ProductName #")
        .HeaderTemplate("<div class=\"dropdown-header k-widget k-header\">" +
                            "<span>Products</span>" +
                        "</div>")
        .FooterTemplate("Total <strong>#: instance.dataSource.total() #</strong> items found")
        .Filter("contains")
        .MinLength(3)
        .HtmlAttributes(new { style = "width:100%" })
        .Height(520)
        .DataSource(source =>
        {
            source.Read(read =>
            {
                read.Action("GetProducts", "Home")
                    .Data("onAdditionalData");
            })
            .ServerFiltering(true);
        })
    )

    <script type="text/javascript">
        function onAdditionalData() {
            return {
                text: $("#autocomplete").val()
            };
        }
    </script>
```

```C# Controller
    public JsonResult GetProducts(string text)
    {
        // filter the data based on the text value
        // return an IEnumerable collection to the view     
        return Json(products.ToList(), JsonRequestBehavior.AllowGet);
    }
```

## Functionality and Features

* [Data binding](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/autocomplete/binding/binding-overview)—The AutoComplete supports multiple data binding approaches: server, model, custom, and ajax binding.
* [Grouping](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/autocomplete/grouping)—You can group the data that is displayed in the AutoComplete.
* [Templates](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/autocomplete/templates)—To take full control over the rendering of the AutoComplete items, popup header, and popup footer, you can use the available templates.
* [Virtualization](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/autocomplete/virtualization)—The built-in virtualization allows you to display large datasets.
* [Accessibility](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/autocomplete/accessibility/overview)—The AutoComplete is accessible by screen readers and provides WAI-ARIA, Section 508, WCAG 2.2, and keyboard support.

## Next Steps

* [Getting Started with the AutoComplete](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/autocomplete/getting-started)
* [Basic Usage of the AutoComplete HtmlHelper for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/autocomplete/index)

## See Also

* [Using the API of the AutoComplete for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/autocomplete/api)
* [Knowledge Base Section](https://www.telerik.com/aspnet-mvc/documentation/knowledge-base)
