有谁知道与渲染不正确查询字符串在Ajax.ActionLink使用htmlAttributes当任何问题?看来,如果我把即使是空数组中的htmlAttributes,链接被渲染不正确。这是我的code。
Does anyone know of any issues with rendering incorrect querystrings when using htmlAttributes in an Ajax.ActionLink? It seems that if I put even an empty array in for the htmlAttributes, the link gets rendered incorrectly. Here's my code.
当我这样做(注意新{}):
When I do this (note the new { }):
<%= Ajax.ActionLink("Delete", "Delete", "Milestone", new RouteValueDictionary { { "id", Model.Id } }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "ModalDeleteContainer", OnSuccess = "modalDelete" }, new { })%>
链接呈现这样的:
The link renders like this:
<a href="/Client/1/Admin/Milestone/Delete?Count=1&Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object%5D&Values=System.Collections.Generic.Dictionary%602%2BValueCollection%5BSystem.String%2CSystem.Object%5D" onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, httpMethod: 'GET', updateTargetId: 'ModalDeleteContainer', onSuccess: Function.createDelegate(this, modalDelete) });">Delete</a>
当我这样做(而不是空新{}):
When I do this (null instead of new { }):
<%= Ajax.ActionLink("Delete", "Delete", "Milestone", new RouteValueDictionary { { "id", Model.Id } }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "ModalDeleteContainer", OnSuccess = "modalDelete" }, null)%>
链接呈现这样的:
The link renders like this:
<a href="/Client/1/Admin/Milestone/Delete/703c749e-c145-4cf1-90eb-9bee00bac79d" onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, httpMethod: 'GET', updateTargetId: 'ModalDeleteContainer', onSuccess: Function.createDelegate(this, modalDelete) });">Delete</a>
两者之间唯一的区别是在Ajax.ActionLink结束时htmlAttributes参数。感谢您的见解!
The only difference between the two is the htmlAttributes argument at the end of the Ajax.ActionLink. Thanks for any insight!
您需要使用方法正确的过载。您所使用的接受一个IDictionary的,这就是为什么它的渲染事情是这样的。
You need to use the correct overload of the method. The one you are using takes an IDictionary and that's why it's rendering the way it is.
如果您选择的对象RouteValues和对象htmlAttributes这样的:
If you choose the object RouteValues and object htmlAttributes like this:
<%= Ajax.ActionLink("Delete", "Delete", "Milestone", new { id = Model.Id },
new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "ModalDeleteContainer",
OnSuccess = "modalDelete" }, new { })%>
它将所有的工作!
it will all work!