Invoking particular action on dropdown list selection in MVC

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

    Like both : D

    I propose a mix -I like a lot the jQuery.

    $('ddl').change(
     function() {
      // This contains your selected option val
      $(this).val();
    
    // so you can do domething like...
      $.post(
        $(this).val(),
        { Param1: xxxx,
          Param2: xxxx,
          Param3: xxxx },
        function(data) {
         // handle your call here. 'data' contains the response
        } );
    }
    

提交回复
热议问题