gpt4 book ai didi

asp.net-mvc-3 - 更改下拉列表中的值时的页面重定向

转载 作者:行者123 更新时间:2023-12-05 00:38:17 24 4
gpt4 key购买 nike

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

我有以下代码,但这不起作用,当我检查 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;" })

关于asp.net-mvc-3 - 更改下拉列表中的值时的页面重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5770197/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com