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
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.
function onBegin(xhr, request)
{
request.url = "@Url.Action("SomeAction", "SomeController")/" + $("ddl").val();
}
HTH
Si