This project is read-only.


this helper will create a list of radiobuttons, you can call it like this:

<%=Html.AjaxRadioList("Fruit") %>
<%=Html.AjaxRadioList("Fruit", controller: "FruitAjaxRadioList") %>

it requires a controller to get it's data from, if the controller's name is not specified it will search for Prop + "AjaxRadioList" (Fruit + AjaxRadioList)
the controller must have an Action GetItems with a key parameter and it should return a Json made from an IEnumerable<SelectListItem>
public class FruitAjaxRadioListController : Controller
        public ActionResult GetItems(int? key)
            var res = repo.GetAll().Select(o => new SelectListItem { Text = o.Name, Value = o.Id.ToString(), Selected = (key == o.Id) });

            return Json(res);

you can also call it like this:
<%=Html.EditorFor(o => o.Fruit) %>

for this in your ViewModel you will need to do something like this:
[AjaxRadioList(Controller = "FruitAjaxRadioList")]
public int? TheFruit { get; set; }

public int? Fruit { get; set; }

just like the AjaxDropdown you can bind it with other inputs by specifying the ParentId in the attribute or in the helper's parameters

Last edited May 12, 2011 at 2:58 PM by o, version 3


No comments yet.