更新时间:2023-02-01 10:49:15
好吧,将近 2 年后,你可能不再关心了.谁知道:也许其他人(例如我 ;-) 会这样做.
OK, nearly 2 years later, you probably don't care anymore. Who knows: Maybe others (such as me ;-) do.
所以这是(非常简单的)解决方案:
So here's the (extremely simple) solution:
在您的 Html.DropDownList(...)
调用中,更改
In your Html.DropDownList(...)
call, change
new { onchange = "this.form.submit()" }
到
new { onchange = "this.form.onsubmit()" }
你能看出区别吗?;-)
Can you spot the difference? ;-)
原因是 Ajax.BeginForm()
创建一个带有 onsubmit()
处理程序的表单来异步提交表单.通过调用 submit()
,您可以绕过这个 onsubmit()
自定义处理程序.调用 onsubmit()
对我有用.
The reason is that Ajax.BeginForm()
creates a form with an onsubmit()
handler to submit the form asynchronously. By calling submit()
, you bypass this onsubmit()
custom handler. Calling onsubmit()
worked for me.