User288213138 posted
Hi kengkit,
For Each item As ListItem In Me.CheckBoxList.Items
If item.Text.Contains("YES") Then
item.Enabled = False
item.Attributes.Add("style", "color:#FF0046; text-decoration-line: line-through;")
End If
Next
I tesed your code, it works fine in my chrome brower. Are you running your application in the IE or Edge brower?
My test code:
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem Text="YES"></asp:ListItem>
<asp:ListItem Text="NO"></asp:ListItem>
</asp:CheckBoxList>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
For Each item As ListItem In Me.CheckBoxList1.Items
If item.Text.Contains("YES") Then
item.Enabled = False
item.Attributes.Add("style", "color:#FF0046; text-decoration-line: line-through;")
End If
Next
End Sub
The result:

Note: The text-decoration-line property is not compatible with Edge and IE.
More information about text-decoration-line property you can refer to this link:https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-line
Best regards,
Sam