0
I created a dropdownlist in Asp.net linked to a database. Now I want a message to appear as soon as one of the values of db is selected.
(Ex: A dropdownlist with three values "A", "B", "C". When I click on "B", a message appears saying, "You chose B).
Follows 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")
It still doesn’t work, I didn’t think to use jquery and I didn’t find how to put the id in select
– bcastro1995
@bcastro1995, asks the question the code of its
View
, please, after that I will edit the question withjavascript
only– Barbetta
@bcastro1995 updated with javascript
– Barbetta