Autocomplete needs an url, controller or data function (js func) to get data from, by default convention it will look for a controller with the same name as it + "Autocomplete"

  • action GetItems - gets the items for the autocomplete, it will receive a v parameter which represents the value of the textbox

Custom Item rendering


Achieving custom item rendering by setting ItemFunc, we're reusing the site.imgItem used by the imgDropdown but any js function that receives an object (KeyContent inheritant MealDisplay) and returns a string will do.

Storing selected value key in a separate field using .PropId

you can (should) use hidden input instead

when the user selects a value from the autocomplete lists the PropId will be assigned the key of the selected value, but if the user will type something into the autocomlete after that the propId value will clear

Using DataFunc and ItemFunc

git repo:

using DataFunc to get data from github api, ItemFunc is used to set a custom js function that will render the item
git repo: 
@(Html.Awe().Autocomplete(new AutocompleteOpt{
Name = "Repo",
DataFunc = "getGit",
ItemFunc = "site.gitItem"
function getGit(v) {
return $.get('', { q: v })
.then(function (data) {
return $.map(data.items,
function (item) {
return { k:, c: item.full_name, avatar: item.owner.avatar_url, desc: item.description };

Numeric autocomplete

Prime number:
@(Html.Awe().Autocomplete(new AutocompleteOpt
Name = "PrimeNumber",
Url = Url.Action("GetItems", "PrimesAutocomplete"),
Numeric = true,
Placeholder = "type a prime number"