如何设置复选框内部的颜色 - asp.net

时间:2010-07-21 17:48:08

标签: asp.net

我正在尝试设置复选框的内部颜色(通常为白色的部分,等待勾选\检查)。如何将其设置为不同的颜色,而不是默认颜色?

谢谢!

2 个答案:

答案 0 :(得分:2)

你无法用css做到这一点。众所周知,表格很难设计(technical explanation from Eric Meyer)。

但是,您可以使用javascript完全替换带有图像的复选框,但仍保留普通复选框元素的表单编码。 Here's an example using jquery

答案 1 :(得分:1)

Public Sub SetColor()
    Try
        For i As Integer = 0 To gvMaster.Rows.Count - 1
            FN = gvMaster.Rows(i).Cells(3).Text
            If FN = "Present" Then
                gvMaster.Rows(i).Cells(3).ForeColor = Color.Green
            End If
            If FN = "Absent" Then
                gvMaster.Rows(i).Cells(3).ForeColor = Color.Red
            End If

            AN = gvMaster.Rows(i).Cells(4).Text
            If AN = "Present" Then
                gvMaster.Rows(i).Cells(4).ForeColor = Color.Green
            End If
            If AN = "Absent" Then
                gvMaster.Rows(i).Cells(4).ForeColor = Color.Red
            End If
        Next
    Catch generatedExceptionName As Exception
    End Try
End Sub