public ViewResult CascadingDropDown() { var viewModel = new CascadingDropDownViewModel(); viewModel.ContinentList = GetContinents(); return View(viewModel); }
public ViewResult CascadingDropDown(CascadingDropDownViewModel viewModel) { if (viewModel.ContinentId != (int)Continent.Antarctica && viewModel.CountryId == null) { ModelState.AddModelError("CountryId", "Please select a country."); } if (ModelState.IsValid) { ViewBag.Message = "Selected"; } viewModel.ContinentList = GetContinents(); viewModel.CountryList = GetCountries(viewModel.ContinentId); return View(viewModel); }