Invoking particular action on dropdown list selection in MVC

后端 未结 7 1990
时光取名叫无心
时光取名叫无心 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:47

    Do you really need to submit the form? You could redirect:

    onchange = "redirect(this.value)"
    

    where redirect is a custom defined function:

    function redirect(dropDownValue) {
        window.location.href = '/myController/myAction/' + dropDownValue;
    }
    

提交回复
热议问题