AutoComplete Searching

By default, the AutoComplete control searches for matches against the property specified by the displayMemberPath property. You can extend the search to other properties by setting the searchMemberPath property to a comma-delimited list of properties to search on.

For example, the AutoComplete below is configured to search for country and continent names. Try typing "asia", "america", or "euro or" for example:

1
2
3
4
5
6
7
8
9
10
11
12
13
using System.Web.Mvc;
 
namespace LearnMvcClient.Controllers
{
    public partial class C1InputController : Controller
    {
        // GET: AutoCompleteSearchPath
        public ActionResult AutoCompleteSearchPath()
        {
            return View(Models.Gdp.GetData());
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
@model IEnumerable<Gdp>
 
<h1>
    @Html.Raw(Resources.C1Input.AutoCompleteSearchPath_Title)
</h1>
 
<p>
    @Html.Raw(Resources.C1Input.AutoCompleteSearchPath_Text1)
</p>
<p>
    @Html.Raw(Resources.C1Input.AutoCompleteSearchPath_Text2)
</p>
 
<label for="theAutoComplete">@Html.Raw(Resources.C1Input.AutoCompleteSearchPath_Text3)</label>
@(Html.C1().AutoComplete<Gdp>().Id("theAutoComplete").Bind(Model).DisplayMemberPath("Country").SearchMemberPath("Country,Continent"))