在下拉列表中更改值时的页面重定向

egi*_*gil 4 asp.net-mvc-3

我有以下代码创建一个下拉列表.
当用户选择一个项目时,我想在控制器中调用某个动作并将新值作为参数传递.

我有以下代码,但这不起作用,当我检查Firebug时,我得到"无效的正则表达式C".

            @Html.DropDownList(
                "ctrlName", 
                items, 
                null,
                new { onchange = "document.location.href = /Controller/Action/this.options[this.selectedIndex].value;" })
Run Code Online (Sandbox Code Playgroud)

Luk*_*tný 5

你在js中缺少引号

@Html.DropDownList(
    "ctrlName", 
    items, 
    null,
    new { onchange = "document.location.href = '/Controller/Action/' + this.options[this.selectedIndex].value;" })
Run Code Online (Sandbox Code Playgroud)