Using ASP.NET MVC Preview 4 Code:
<%= Html.CheckBox( "myCheckBox", "Click Here", "True", false ) %>
outputs only:
<input type="checkbox" value="True" name="myCheckBox" />
There is a name for the post back form, but no id for javascript or labels: - (
I was hoping to change it to:
Html.CheckBox( "myCheckBox", "Click Here", "True", false, new { id="myCheckBox" } )
will work, but instead I get an exception:
System.ArgumentException: An item with the same key has already been added.
As if there was already somewhere in the collection somewhere - I'm at a standstill!
A complete exception for any interested person (hey - it would not be a bad idea to attach files here):
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