动态的Ajax ActionLink的RouteValues [英] Dynamic Ajax ActionLink RouteValues
问题描述
我有一个ActionLink的链接此
I have an ActionLink link this
@Ajax.ActionLink("Delete it!", "Delete", new {id = getTheID}, new AjaxOptions { Confirm = "Really?", HttpMethod = "Delete", UpdateTargetId = "ddlRoles" })
和我想要插入单击路径值身份证。 我想从读取的值是一个下拉列表,所以我得到了这样的事情在JavaScript中获得的价值:
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()
我已经读过这篇文章 设置ActionLink的routeValues动态的 但我不知道如何语法应该是这样,有人可以帮我吗?
I already read this post set ActionLink routeValues dynamically but I'm not sure how the syntax should look like, can someone help me?
问候
推荐答案
使用的AJAX选项OnBegin超载。其中传递的参数是请求对象。
Use the OnBegin overload of the ajax options. One of the parameters passed in is the request object.
您可以拉的价值出来的DropDownList的出现和修改URL。
You could pull the value out of the dropdownlist there and amend the Url.
function onBegin(xhr, request)
{
request.url = "@Url.Action("SomeAction", "SomeController")/" + $("ddl").val();
}
心连心
硅
这篇关于动态的Ajax ActionLink的RouteValues的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!