Asp.net mvc 3 更改下拉列表中的值时的页面重定向
我有以下创建下拉列表的代码。Asp.net mvc 3 更改下拉列表中的值时的页面重定向,asp.net-mvc-3,Asp.net Mvc 3,我有以下创建下拉列表的代码。 当用户选择一个项目时,我想调用控制器中的某个操作,并将新值作为参数传递 我有以下代码,但这不起作用,当我检查Firebug时,我得到“无效正则表达式C” @Html.DropDownList( "ctrlName", items, null, new { onchange = "document.location
当用户选择一个项目时,我想调用控制器中的某个操作,并将新值作为参数传递 我有以下代码,但这不起作用,当我检查Firebug时,我得到“无效正则表达式C”
@Html.DropDownList(
"ctrlName",
items,
null,
new { onchange = "document.location.href = /Controller/Action/this.options[this.selectedIndex].value;" })
js中缺少引号
@Html.DropDownList(
"ctrlName",
items,
null,
new { onchange = "document.location.href = '/Controller/Action/' + this.options[this.selectedIndex].value;" })
少量添加:请改用window.location
<%:Html.DropDownList("ctrlName", new[]{
new SelectListItem { Text="--Select--", Value="" },
new SelectListItem { Text = "KodefuGuru", Value = "Create" },
new SelectListItem { Text = "PlatinumBay", Value = "PlatinumBay" }
},
null,
new { onchange = "document.location.href = '/Controller/Action/'+this.options[this.selectedIndex].value;)" })%>