AjaxList
This control requires a single SearchUrl which must return a LookupResult object, just like Lookup's SearchUrl.
The AjaxRadioList can be bound to parents (using Data) and predefined values can be sent. The parents thing is useful here for adding search criterias.
To be able to trigger the search you assign a value to the SearchButton property (the ClientID of the button).
example:
<%
FruitsList.Data = new Dictionary<string, string> { { "search", Name.ClientID } };
FruitsList.SearchButton = "bsearch";
%>
<asp:TextBox runat="server" ID="Name"></asp:TextBox>
<input type="button" id="bsearch" value="search" />
<o:AjaxList runat="server" ID="FruitsList" SearchUrl='~/svc/aja.svc/FruitSearch' />
[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
};
}
Adding buttons
Buttons can be added, and for each button a custom javascript function can be assigned, that js function will receive the key of the row as a parameter
(key from KeyContent from LookupResult.Items). A css class can also be added for each button.
example:
FruitsList.Buttons = new[]
{
new AjaxListButton {Content = "id", JsFunc = "alert", CssClass = "something"}
};
