Reputation: 44295
I want to postback and pass in a parameter onchange
. I have
@Html.DropDownList("CategoryID", (System.Collections.Generic.IEnumerable<System.Web.Mvc.SelectListItem>)@Model.PhaseNames, new { @onchange = "location.href='/Home/Index?phaseFilter=this.value;'" })
This nearly works. this.value
is not replaced with the selected option value as I would expect. Also, is there a better way to create the URL in this case?
Upvotes: 0
Views: 816
Reputation: 4732
This should work:
@Html.DropDownList("CategoryID", (IEnumerable<SelectListItem>)@Model.PhaseNames, new { @onchange = "location.href='/Home/Index?phaseFilter=' + this.value;" })
Upvotes: 2
Reputation: 96606
I guess you wanted to write the onchange
part like this:
@onchange = "location.href='/Home/Index?phaseFilter=' + this.value;"
Upvotes: 1