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
Post a Comment