Invoking particular action on dropdown list selection in MVC

后端 未结 7 1779
时光取名叫无心
时光取名叫无心 2021-02-01 18:08

I have a dropdown list in an MVC view. On selection change of dropdown list I want to call specific action method in the controller.

What I have done on view is this :

7条回答
  •  不思量自难忘°
    2021-02-01 18:49

    This is a jQuery thing. Give it a class and wire up to it.

    Html.DropDownList("ddl", AvailableList, new { @class = "_select_change" })
    

    A rough script might look like this:

    $('._select_change').change(function() { $.post(ctrlUrl); })
    

提交回复
热议问题