AjaxList Demo





    by default the AjaxList will try to get data from the Search action of a controller with same name as it + "AjaxList" but a different Url or controller can be specified using .Url or .Controller extensions

    AjaxListDemo/Index.cshtml
    @Html.Awe().TextBox("txtSearch").CssClass("searchtxt").Placeholder("search...")
    <br />
    <br />
    @(Html.Awe().AjaxList("Meals")
    .Parent("txtSearch"))
    Awesome/AjaxList/MealsAjaxListController.cs
    public class MealsAjaxListController : Controller
    {
    public ActionResult Search(int page, string parent)
    {
    const int PageSize = 5;
    parent = (parent ?? "").ToLower();

    var list = Db.Meals.Where(o => o.Name.ToLower().Contains(parent));

    return Json(new AjaxListResult
    {
    Items = list.Skip((page - 1) * PageSize).Take(PageSize).Select(o => new KeyContent(o.Id, o.Name)),
    More = list.Count() > page * PageSize // bool - show More button or not
    });
    }
    }