2009-04-17 3 views
0

Ajax.ActionLink에서 htmlAttributes를 사용할 때 부정확 한 쿼리를 렌더링하는 데 문제가 있다는 것을 아는 사람이 있습니까? htmlAttributes에 빈 배열을 넣어도 링크가 잘못 렌더링되는 것 같습니다. 여기 내 코드가있다.htmlAttributes를 사용할 때 Ajax.ActionLink가 링크를 잘못 렌더링하는 문제가 발생했습니다.

나는이 작업을 수행 할 때 (새로운 {}주의) :

<%= Ajax.ActionLink("Delete", "Delete", "Milestone", new RouteValueDictionary { { "id", Model.Id } }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "ModalDeleteContainer", OnSuccess = "modalDelete" }, new { })%> 

링크는 다음과 같이 렌더링 :

<a href="/Client/1/Admin/Milestone/Delete?Count=1&amp;Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object%5D&amp;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> 

나는이 할 때 (대신 null의 새로운 {}) :

<%= Ajax.ActionLink("Delete", "Delete", "Milestone", new RouteValueDictionary { { "id", Model.Id } }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "ModalDeleteContainer", OnSuccess = "modalDelete" }, null)%> 

링크는 다음과 같이 렌더링 :

<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 인수입니다. 어떤 통찰력을 가져 주셔서 감사합니다!

답변

2

올바른 오버로드를 사용해야합니다. 당신이 사용하고있는 것은 IDictionary를 필요로하기 때문에 그것이 그것이 그대로 표현됩니다.

이 같은 객체 RouteValues ​​및 객체 htmlAttributes 선택하는 경우 :

<%= Ajax.ActionLink("Delete", "Delete", "Milestone", new { id = Model.Id }, 
new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "ModalDeleteContainer", 
OnSuccess = "modalDelete" }, new { })%> 

이 모든 일을!

+0

굉장하다. 감사! –

관련 문제