Suja Shyam
Suja Shyam

Reputation: 971

Autocomplete dropdown using asp.net mvc

I have a dropdown in my CreateDocumentTemplate ciew
<%=Html.DropDownList("Part", (SelectList)ViewData["Part"])%>
which is populated from database. I want to this dropdown to be autocomplete. How can I acoomplish this?

Upvotes: 3

Views: 22556

Answers (3)

Vladimir Georgiev
Vladimir Georgiev

Reputation: 1949

If you want a pure MVC component that you want to use directly in your Razor views - take a look at Shield UI's auto complete combobox.

Sample usage is shown here:

@(Html.ShieldComboBox()
    .Name("widget")
    .HtmlAttribute("value", "Chart")
    .DataSource(ds => ds.Remote(remote => remote.Read("/api/demo-stats"))
        .Schema(schema => schema.Data("components"))
        .FilterGroup(
            Shield.Mvc.UI.DataSource.FilterCondition.And,
            new object[] {
                new Dictionary<string, object>() {
                    {"path", "name"}, 
                    {"filter", "contains"},
                    {"value", ""}
                }
            }))
    .TextTemplate("{name}")
    .ValueTemplate("{name}")
    .AutoComplete(ac => ac.Enabled(true)))

Upvotes: 0

ilmatte
ilmatte

Reputation: 1902

I wrote an Asp.Net WebControl wrapping the JQuery UI autocomplete widget.

You can find it and the relative documentation at:

http://autocompletedotnet.codeplex.com/

Hope it can help

Upvotes: 0

Gideon
Gideon

Reputation: 18491

Use for example jQueryUI (even comes packaged with MVC 3)

http://jqueryui.com/demos/autocomplete/#combobox

Upvotes: 7

Related Questions