I created a dropdownlist in asp.net linked to a database. Now I want a message to appear as soon as one of the db values is selected.
(Ex: A dropdownlist with three values "A", "B", "C".) When I click on "B", a message appears saying: "You chose B.
Follow the code
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult dbExample()
{
copaDBEntities entity = new copaDBEntities();
var getCopaList = entity.copa.ToList();
SelectList list = new SelectList(getCopaList, "id", "ano");
ViewBag.copalistano = list;
return View();
}
}
View
@{
ViewBag.Title = "dbExample";
}
<h2>Copa do Mundo</h2>
@Html.DropDownList("CopaList", ViewBag.copalistano as SelectList, "Selecione o ano")