3

I have a DropDownList in an MVC 4 web application that is used as a filter. When a new value is selected from the drop down, the user then has to click the submit button. Is there a way to get the DropDownList to perform the same submit action when a new item is selected from the drop down so I can eliminate the submit button altogether? No custom methods have been written for the submit button, I am just using the generic one that is in MVC.

Update: Code is as follows:

@Html.DropDownList("userName",Model.Users) <input type="submit" value="Search" />
Matt Rockwell
  • 456
  • 1
  • 6
  • 20

1 Answers1

7
<select name="dropdown" id="dropdown" onchange="this.form.submit()">

p.s. first link in Google search results

Edit

@Html.DropDownList("userName",Model.Users new {onchange="this.form.submit()"}) 
swapneel
  • 3,061
  • 1
  • 25
  • 32
  • this is quite a bit different than what I am dealing with. I have updated the question to contain my code. – Matt Rockwell Aug 01 '12 at 17:01
  • 1
    Does this help? http://stackoverflow.com/questions/8973037/handling-onchange-event-in-html-dropdownlist-razor-mvc – swapneel Aug 01 '12 at 17:33