@{
ViewData["Title"] = "Home Page";
}
<h2>Read Only Checkbox</h2>
<br />
@Html.CheckBox("chkTerm", false, new { @class = "form-check-input", @disabled = "disabled" })
Disable check box with checked false
<br />
@Html.CheckBox("chkTerm", true, new { @class = "form-check-input", @disabled = "disabled"})
Disable check box with checked true
In above code I have taken two checkboxes control on with check and one with un-checked property. To make the checkbox checked we will pass the value as true and to make the checkbox un-checked we will pass false.Now we will make the checkbox readonly we will use the property disabled="disabled". This will make the checkbox read only and user will not be able to click on it. Now we will the run the code to check the output.
Now to make the check box enable we only need to remove disabled="disabled". Here is the code with no disabled="disabled" tag.
@Html.CheckBox("chkTerm", false, new { @class = "form-check-input"})
Disable check box with checked false
<br />
@Html.CheckBox("chkTerm", true, new { @class = "form-check-input" })
Disable check box with checked true
Now run the code to check the output.