I was wondering how you make a CheckBox
unselectable in c#? I thought it would be something like SetSelectable (false) or something but I can't seem to see the method.
I found CanSelect
but this seems to be a read only property.
Practically speaking, this is the solution that many of us are looking for. How to make the checkbox un-changeable (answer: disable it) but still preserve the value of whether it is checked or not upon save (answer: use a hidden input type). Make sure to only add the hidden input if you have also disabled the checkbox.
You can style checkbox label and readonly inputs with CSS, e.g.: input [readonly="readonly"] {} but the browser should make the checkbox should appear greyed out when set to readonly. "checkbox itself should appear greyed out just by setting the readonly attribute" - Tried in IE8, FF12. 0, Chrome. Only works in Chrome.
If the checkbox is readonly, it won't change. If it's not, it will. It does use jquery, but you're probably using that already... It works.
You can set AutoCheck property to false
.
You can set the Enabled
property to false
:
checkBox1.Enabled = false;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With