المشكلة مع اياكس.ActionLink بشكل غير صحيح مما يجعل الروابط عند استخدام htmlAttributes

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

سؤال

لا أحد يعرف من أي مشاكل مع تقديم غير صحيحة querystrings عند استخدام htmlAttributes في اياكس.ActionLink?ويبدو أنه إذا كنت وضعت حتى صفيف فارغ في 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>

الفرق الوحيد بين الاثنين هو htmlAttributes حجة في نهاية اياكس.ActionLink.شكرا على أي فكرة!

هل كانت مفيدة؟

المحلول

تحتاج إلى استخدام الصحيح الزائد من طريقة.واحد كنت تستخدم يأخذ يقع و هذا هو السبب في أنه يرجع على ما هو عليه.

إذا اخترت الكائن RouteValues وجوه 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