将 DropDownList 的选定项目传递给 ajaxy 调用的操作
我需要以 ajaxy 方式将列表中所选项目的值传递给操作:
View:
<%= Html.DropDownList("ApplicationColumns", applicationColumns, new { @style = "width: 200px;" })%>
<%= Ajax.ActionLink("AddColumnToTrim", "AddColumnToTrim", new { columnName = ??? }, new AjaxOptions() { UpdateTargetId = "columnsDiv" })%>
<div id="columnsDiv"></div>
我这样做是因为我无法发布整个表单,只需要根据所选项目和显示执行一些逻辑它在局部视图中。 如何将 DropDownList 所选项目的值(或所选 SelectListItem)传递给我的操作?谢谢。
I need to pass the value of on of the selected item in the list to the action in ajaxy way:
View:
<%= Html.DropDownList("ApplicationColumns", applicationColumns, new { @style = "width: 200px;" })%>
<%= Ajax.ActionLink("AddColumnToTrim", "AddColumnToTrim", new { columnName = ??? }, new AjaxOptions() { UpdateTargetId = "columnsDiv" })%>
<div id="columnsDiv"></div>
I'm doing this cause I cannot post the whole form and just need to execute some logic depending on the chosen item and display it in partial view.
How can I pass the value(or selected SelectListItem) of the selected item of the DropDownList to my action please ? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用表单将是执行此操作的语义上正确的方法:
现在,提交此表单时,下拉列表的选定值将使用 AJAX 调用自动发送到控制器操作:
并且,是的,您可以 设置此按钮的样式使其看起来像一个锚点。
Using a form would be the semantically correct way to do this:
Now the selected value of the dropdown will be automatically sent to the controller action using an AJAX call when this form is submitted:
And, yes, you could style this button to look like an anchor.