How will you call a JavaScript function on the change of dropdownlist in ASP.NET MVC?

How will you call a JavaScript function on the change of dropdownlist in ASP.NET MVC?

-Suppose we are having a Dropdown for Employees list.

-Create a java-script function:
<script type="text/javascript">
function employeeSelected () {
}
</script>

-Call this function from a dropdown as described below.
<%:Html.DropDownListFor(x => x.SelectedEmployee, new SelectList(Model.Employees, "Value", "Text"), "Please Select a Employee", new { id = "ddlEmployees", onchange="employeeSelected()" })%>

-In this way we can call a JavaScript function on the change of dropdownlist in ASP.NET MVC.
Post your comment