动态 Ajax ActionLink RouteValues
我有一个 ActionLink 链接
@Ajax.ActionLink("Delete it!", "Delete", new {id = getTheID}, new AjaxOptions { Confirm = "Really?", HttpMethod = "Delete", UpdateTargetId = "ddlRoles" })
,我想在单击时插入路由值“id”。 我想读取的值是一个下拉列表,因此我在 javascript 中得到了类似的内容来获取值:
$('#ddlRoles :selected').val()
我已经阅读了这篇文章 动态设置 ActionLink 路由值 但我不确定语法应该是什么样子,有人可以帮助我吗?
问候
I have an ActionLink link this
@Ajax.ActionLink("Delete it!", "Delete", new {id = getTheID}, new AjaxOptions { Confirm = "Really?", HttpMethod = "Delete", UpdateTargetId = "ddlRoles" })
and I want to insert the route value "id" on click.
The value I want to read from is a drop-down list, so I got something like this in javascript to get the value:
$('#ddlRoles :selected').val()
I already read this post
set ActionLink routeValues dynamically
but I'm not sure how the syntax should look like, can someone help me?
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 ajax 选项的 OnBegin 重载。传入的参数之一是请求对象。
您可以从下拉列表中提取值并修改网址。
高温TH
硅
Use the OnBegin overload of the ajax options. One of the parameters passed in is the request object.
You could pull the value out of the dropdownlist there and amend the Url.
HTH
Si
我知道这是一篇很旧的帖子,但我只是在寻找类似的解决方案。根据上面 Slicksim 的回答和 Adam Tuliper 的评论,我使用 data- 属性实现了以下解决方案,以允许重复使用 JavaScript 函数。所以我想我应该发帖来帮助别人。
I know this is a pretty old post, but I was just looking for a similar solution. Based on Slicksim's answer above and the comment from Adam Tuliper, I implemented the below solution using the data- attribute to allow for a repeatably used javascript function. So I thought I would post to help others.