ajax.actionLink의 문제 htmlattributes를 사용할 때 링크를 잘못 렌더링합니다

StackOverflow https://stackoverflow.com/questions/761288

문제

Ajax.actionLink에서 htmlattributes를 사용할 때 잘못된 쿼리 스트링을 렌더링하는 데 문제가있는 사람이 있습니까? htmlattributes에 빈 배열을 넣으면 링크가 잘못 렌더링되는 것 같습니다. 여기 내 코드가 있습니다.

내가 이것을 할 때 (새로운 {} 참고) :

<%= 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 인수입니다. 통찰력에 감사드립니다!

도움이 되었습니까?

해결책

메소드의 올바른 오버로드를 사용해야합니다. 당신이 사용하고있는 사람은 유물을 취하기 때문에 그것이 그 방식대로 렌더링하는 이유입니다.

객체 lourtevalues와 객체 htmlattributes를 선택하면 다음과 같이합니다.

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

그것은 모두 작동합니다!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top