我想回发并传入参数onchange
。我有
@Html.DropDownList("CategoryID", (System.Collections.Generic.IEnumerable<System.Web.Mvc.SelectListItem>)@Model.PhaseNames, new { @onchange = "location.href='/Home/Index?phaseFilter=this.value;'" })
这几乎可行。正如我所料,this.value
不会替换为所选的选项值。另外,在这种情况下是否有更好的方法来创建URL?
答案 0 :(得分:2)
这应该有效:
@Html.DropDownList("CategoryID", (IEnumerable<SelectListItem>)@Model.PhaseNames, new { @onchange = "location.href='/Home/Index?phaseFilter=' + this.value;" })
答案 1 :(得分:1)
我想你想写这样的onchange
部分:
@onchange = "location.href='/Home/Index?phaseFilter=' + this.value;"