yılında HtmlHelper kullanarak işlemek için özel bir kimliği alırım geri amanasıl gibi <a href="http://asp.net/mvc" rel="nofollow noreferrer">ASP.NET MVC</a> Kanununun <a href="http://www.codeplex.com/aspnet" rel="nofollow noreferrer">preview 4</a> kullanarak MVC
:-(javascript veya etiketler için hiçbir id
umuyordum ki değiştirmeyi:
Html.CheckBox("myCheckBox", "Click Here",
"True", false, new { id="myCheckBox" })
çalışacak - ama bunun yerine bir istisna olsun:
System.ArgumentException: An item with the same key has already been added.
Sanki bir yerlerde zaten koleksiyonunda yerde bir kimlik vardı - stumped!
ilgilenen herkes izler tam istisna (hey - burası dosyaları eklemek hoş olmaz):
System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Web.Routing.RouteValueDictionary.Add(String key, Object value) at System.Web.Mvc.TagBuilder2.CreateInputTag(HtmlInputType inputType, String name, RouteValueDictionary attributes) at System.Web.Mvc.CheckBoxBuilder.CheckBox(String htmlName, RouteValueDictionary htmlAttributes) at System.Web.Mvc.CheckBoxBuilder.CheckBox(String htmlName, String text, String value, Boolean isChecked, RouteValueDictionary htmlAttributes) at System.Web.Mvc.CheckBoxExtensions.CheckBox(HtmlHelper helper, String htmlName, String text, String value, Boolean isChecked, Object htmlAttributes) at ASP.views_account_termsandconditions_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\dev\myProject\Views\Account\Edit.ascx:line 108
Bu dokümantasyonda nerede belirtilir? –
Dokümantasyonda olup olmadığını bilmiyorum. Onu bulamadım. Sanırım Phil Haacks'in blogunda okudum. Ayrıca, önekin bir alt çizgi üzerinde bir @ olarak değiştirildiğini düşünüyorum, bu nedenle yukarıdakiler işe yaramazsa "yeni {@ id =" testini "deneyin. –