I am trying to trigger an action method for onchange event for dropdownlist, how can I do this without using jquery onchange.
@Html.DropDownList("Sortby",
new SelectListItem[]
{
new SelectListItem() { Text = "Newest to Oldest", Value = "0" },
new SelectListItem() { Text = "Oldest to Newest", Value = "1" }})
Thanks
If you have a list view you can do this:
Define a select list:
Use the defined SelectList, creating a diferent id for each record (remember that id of each element must be unique in a view), and finally call a javascript function for onchange event (include parameters in example url and record key):
onchange function can be something as:
You can do this
If you don't want jquery then you can do it with javascript :
You can try this if you are passing a value to the action method.
Remove the query string in case of no parameter passing.