MVC
Web forms
Web forms Tutorials

AjaxDropdown

It can be declared using the AjaxDropdown or AjaxDropdownFor helper like this:
@Html.Awe().AjaxDropdownFor(o => o.Category) 
@Html.Awe().AjaxDropdown("Meal").Parent("Category") 
It needs a controller or url to get data from, by default convention it will look for a controller with the same name as it + "AjaxDropdown", example:
    public class MealAjaxDropdownController : Controller
    {
        public ActionResult GetItems(int? v, int? parent)
        {
            return Json(Db.Meals.Where(o => o.Category.Id == parent)
                            .Select(o => new SelectableItem(o.Id, o.Name, v == o.Id)));// key, text, selected
        }
    }
  • action GetItems - gets the items for the dropdown, it will receive a v parameter which represents the current value
  • .Url - Set the Url to get data from. When url has value Controller, Action and Area are ignored.
  • .Parent - Add a Parent element. On load the value of the parent is sent to the server. When the value of a parent is changed, load on this element will be triggered.
  • .Parameter - Set a parameter. On load parameters are sent to the server.
  • .Prefix - Set Prefix for the html id (use to achieve unique ids for elements with same name).
  • .Value - Set the value of the text input element. If this value is null, the value of the element is retrieved from the System.Web.Mvc.ViewDataDictionary object. If no value exists there, the value is retrieved from the System.Web.Mvc.ModelStateDictionary object..