HOW TO CALL JAVASCRIPT FUNCTION ON THE CHANGE OF DROPDOWNLIST IN ASP.NET MVC?

Chris Anderson

Total Post:197

Points:985
Posted by  Chris Anderson
 5924  View(s)
Ratings:
Rate this:
  1. Chris Anderson

    Post:197

    Points:985
    How to call javascript function on the change of dropdownlist in ASP.Net MVC?

    Create a java-script function:

    <script type="text/javascript">
                function selectedIndexChanged() {
                }
    </script>

    Call the function:

    <%:Html.DropDownListFor(x => x.SelectedProduct, new SelectList(Model.Products, "Value", "Text"), "Please Select a product", new { id = "dropDown1", onchange="selectedIndexChanged()" })%> 

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!