I just noticed that Html.CheckBox(\"foo\")
generates 2 inputs instead of one, anybody knows why is this so ?
As of 2020/11 and .NET 5 being in preview, there is a pull request that should make this behavior controllable. Thank you guys!
Anyway if someone founds it useful, .NET Core 3.0 port of Alexander Trofimov's answer:
public static IHtmlContent CheckBoxSimple(this IHtmlHelper htmlHelper, string name)
{
TextWriter writer = new StringWriter();
IHtmlContent html = htmlHelper.CheckBox(name);
html.WriteTo(writer, HtmlEncoder.Default);
string checkBoxWithHidden = writer.ToString();
string pureCheckBox = checkBoxWithHidden.Substring(0, checkBoxWithHidden.IndexOf("