使用所选选项值回发onchange

时间:2012-08-14 18:36:15

标签: c# asp.net-mvc-3

我想回发并传入参数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?

2 个答案:

答案 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;"