asp.net mvc - Sending form with Select List -


i using code post value of selected item view controller

@using (html.beginform()) {         @html.dropdownlistfor(model => model.myvar, (selectlist)viewdata["list"])         <button name="button" value="valider">valider</button>  } 

is there way send value when selection change in select list (without need click on button) ?

yes can via jquery, on dropdown selection change post form via jquery:

add id drop down:

@html.dropdownlistfor(model => model.myvar, (selectlist)viewdata["list"], new { id="someid"}) 

and write jquery event:

$(function(){      $("#someid").change(function(){          $(this).closest("form").submit(); // post form     });     }); 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

Error while updating a record in APEX screen -

c++ - In an add-in in Excel, written in C(++), how does one get the name of the function which called into the addin? -