Autopost back in mvc drop down list

前端 未结 4 861
借酒劲吻你
借酒劲吻你 2021-01-03 00:22

Requirment: I have a drop down list on my view page, displaying a list of vendors. When a vendor is selected from the dropdown, the page displays the details of selected ven

4条回答
  •  独厮守ぢ
    2021-01-03 00:54

    Assuming you will need to do a database hit to get the results, inside James D'Angelo'a jquery function you would then do a .post on the vendor details method in your controller to get your object back and then you populate the details for the selected vendor to the page. You will have to add a method to the controller that returns a json object

    $.post("/{Controller}/{Method}", { VendorId: selectVal }, function(response, status) {
        var vendorDetails = eval("(" + response + ")");
        //additional code to populate the fields
    

提交回复
热议问题