MVC
Web forms
Web forms Tutorials

Lookup

The Lookup requires 2 urls to service methods:

here's a basic example:

<o:Lookup runat="server" ID="Fruit" GetUrl="~/svc/aja.svc/FruitGet" SearchUrl='~/svc/aja.svc/FruitSearch'  Value="1" />

and the service methods:

[WebGet]
[OperationContract]
public KeyContent FruitGet(string v)
{
    var f = Fruits.Where(o => o.Id.ToString() == v).Single();
    return new KeyContent(f.Id, f.Name);
}

[WebGet]
[OperationContract]
public LookupResult FruitSearch(string search)
{
    var items = Fruits.Where(o => o.Name.Contains(search))
        .Select(f => new KeyContent { Key = f.Id, Content = f.Name });
            
    return new LookupResult
    {
        Items = items
    };
}

Using pagination

As mentioned above to use pagination you need to return a value for the "More" property (more = is there more results) in the LookupResult, so here's an example:

[WebGet]
[OperationContract]
public LookupResult FruitSearch(string search, int page)
{     
    var items = Fruits.Where(o => o.Name.Contains(search))
        .Select(f => new KeyContent { Key = f.Id, Content = f.Name });

    const int pageSize = 5;
    return new LookupResult
    {
        Items = items.Skip((page - 1) * pageSize).Take(pageSize),
        More = items.Count() > page * pageSize
    };
}

Binding to parents, parameters

The Lookup can be bound to one or multiple parents, and parameters with values can be sent, all exactly like the AjaxDropdown, additional parameters (parents, predefined values) will be sent to SearchUrl and GetUrl.

Misc properties

ClearButtonif true will add a "x" button used to clear the value of Lookup
PopupWidth the width in px of the popup window
PopupHeight the height in px of the popup window
FullScreen if true the lookup window will take all the available width and height
Modal Modal Popup true/false