@model Boolean? @{ Layout = "_FieldLayout.cshtml"; var htmlAttributes = new RouteValueDictionary(); if (ViewBag.@class != null) { htmlAttributes.Add("class", ViewBag.@class); } } @Html.CheckBox( "", Model.HasValue && Model.Value, htmlAttributes)