I just noticed that Html.CheckBox(\"foo\")
generates 2 inputs instead of one, anybody knows why is this so ?
You can write a helper to prevent adding the hidden input:
using System.Web.Mvc;
using System.Web.Mvc.Html;
public static class HelperUI
{
public static MvcHtmlString CheckBoxSimple(this HtmlHelper htmlHelper, string name, object htmlAttributes)
{
string checkBoxWithHidden = htmlHelper.CheckBox(name, htmlAttributes).ToHtmlString().Trim();
string pureCheckBox = checkBoxWithHidden.Substring(0, checkBoxWithHidden.IndexOf("
use it:
@Html.CheckBoxSimple("foo", new {value = bar.Id})