Question: How do you implement a filter of the dropdown menu in Razor MVC SelectedListItem using an Html Razor Tag: @Html.DropDownList ?
Every time I call the function the Dropdown menu does not update with the latest SelectListItems.
Please Login to see the rest of the answer
//Front End Side
<form action="toYourFunctionThatWillProcessTheWholeForm">
@html.DropDown("Name", cars,"Select one Item",new {@class="styles"})
@html.DropDown("Name2", cars,"Select one Item",new {@class="styles",@onchange="callBack()"})
</form>
<script>
function callBack(){
var selected = $('#Name').val();
window.location.href = "/MyFunctionAtServerSide"/+selected; //This will get or fetch from MyFunction url, make sure you mark the function with [HttpGet]
//directive otherwise the routing table in Asp.Net will get confused on the url.
}
</script>