Anjani Kumar Agrawal Anjani Kumar Agrawal - 3 months ago 8
C# Question

Disable on Parent Span Not Disabling Child Checkbox in Chrome

So I have C# code that disables a checkbox:

chkbox.Attributes.Add("disabled","disabled");


This adds a new Span parent with disabled attribute to the chkbox.

<span disabled="disabled">
<input id="ctl00_DataContentHolder_chkbox" type="checkbox" name="ctl00$DataContentHolder$chkbox" checked="checked">
</span>


The checkbox is now disabled in IE but not in Chrome. How do I disable it in Chrome by modifying my C# code?

Answer

Try this:

   chkbox.Enabled = false;