0

在 ASP.Net DetailsView 和 GridView 上,我注意到 CheckBoxes 中的刻度线是浅灰色(禁用)颜色,即使我将其设置为蓝色。

<asp:CheckBoxField DataField="DayOfWeekMonday" HeaderText="Monday:" SortExpression="DayOfWeekMonday">
    <ItemStyle ForeColor="Blue" />
</asp:CheckBoxField>

当 CheckBox 是 TemplateField 时,也会发生同样的事情。

<asp:TemplateField HeaderText="Monday:" SortExpression="DayOfWeekMonday">
    <EditItemTemplate>
        <asp:CheckBox ID="CheckBoxEditDayOfWeekMonday" runat="server" Checked='<%# Bind("DayOfWeekMonday") %>' />
    </EditItemTemplate>

    <InsertItemTemplate>
        <asp:CheckBox ID="CheckBoxInsertDayOfWeekMonday" runat="server" Checked='<%# Bind("DayOfWeekMonday") %>' />
    </InsertItemTemplate>

    <ItemTemplate>
        <asp:CheckBox ID="CheckBoxItemDayOfWeekMonday" runat="server" Checked='<%# Bind("DayOfWeekMonday") %>' Enabled="false" />
    </ItemTemplate>

    <ItemStyle ForeColor="Blue" />
</asp:TemplateField>

我也在代码隐藏文件中尝试了这个。

Protected Sub CheckBoxItemDayOfWeekMonday_DataBinding(sender As Object, e As EventArgs)

    Dim theControl As CheckBox

    theControl = DetailsView.FindControl("CheckBoxItemDayOfWeekMonday")
    theControl.ForeColor = Drawing.Color.Blue

End Sub

有没有办法像我们的其他字段和列一样将其更改为蓝色?

4

1 回答 1

0

我注意到您的意思是复选框内的刻度线,而不是前景色。我认为您无法更改此设置,因为这非常依赖于操作系统。我过去已经用图像实现了这一点。您可以尝试这些使用图像的 CSS3 CheckBox:http ://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/quick-tip-easy-css3-checkboxes-and-radio-buttons/

样本:

HTML

<span><input type="checkbox" id="c1" name="cc" />
<label for="c1"><span></span>Check Box 1</label>
</span>

CSS

input[type="checkbox"] {
    display:none;
}

input[type="checkbox"] + label {
    color:#000000;
    font-family:Arial, sans-serif;
    font-size:14px;
}

input[type="checkbox"] + label span {
    display:inline-block;
    width:19px;
    height:19px;
    margin:-1px 4px 0 0;
    vertical-align:middle;
    background:url(http://webdesigntutsplus.s3.amazonaws.com/tuts/391_checkboxes/check_radio_sheet.png) left top no-repeat;
    cursor:pointer;
}

input[type="checkbox"]:checked + label span {
    background:url(http://webdesigntutsplus.s3.amazonaws.com/tuts/391_checkboxes/check_radio_sheet.png) -19px top no-repeat;
}

JSFiddle:http: //jsfiddle.net/4FraV/2/

于 2013-01-23T17:53:59.060 回答