public static HtmlString CheckBox(this HtmlHelper This, string key, object value = null, object htmlAttributes = null)
{
This.RegisterFormField(key);
var tag = new TagBuilder("input");
tag.AddAttribute("type", "checkbox");
tag.AddAttribute("name", key);
tag.AddAttribute("id", key);
tag.AddAttribute("value", "true");
tag.AddAttributes(htmlAttributes);
if ((bool)Convert.ChangeType(This.ResolveFormValue(key, value), typeof(bool)))
{
tag.AddAttribute("checked", "checked");
}
if (!This.Context.ModelState.IsFieldValid(key))
tag.AddClass("model_validation_error");
return new HtmlString(tag.Render());
}