The purpose
I have a simple table listing names (in a partial view), and above it a dropdownlist containing those names. The purpose is to filter th
In your dropdown replace:
new { onchange = "this.form.submit()" }
with:
new { onchange = "$(this.form).submit();" }
Also get rid of all MicrosoftAjax*.js
scripts. Those are completely legacy and shouldn't be used in ASP.NET MVC 3 and newer applications. They are provided only for compatibility reasons if you are migrating from older versions. jQuery.js
and jquery.unobtrusive-ajax.js
are enough.
Not sure if I understand it correctly, but if submit button works OK why not just do this:
@Html.DropDownList("filterName", new SelectList(ViewBag.Names), "Select a name", new { onchange = "clickMe('mybuttonId')" })
and write small script
function clickMe(id) {
$('#' + id).click() // where id is id of button that should submit the form.
}
If you do not want the button to display then just hide it. This is a hack and if it doesn't fit your needs we can investigate further.