【问题标题】:Is there a possibility to assign CssClass to CheckBox within CheckBoxList是否有可能在 CheckBoxList 中将 CssClass 分配给 CheckBox
【发布时间】:2011-05-10 21:45:42
【问题描述】:

我需要为 CheckBoxList 中的每个 CheckBox 分配显示样式(CssClass)。我想为每个 CheckBox 单独做。 最后一个要求是我必须在我的 .net 代码中的服务器端执行此操作。

【问题讨论】:

  • 当你说你想为每个 CheckBox 单独做这件事时,这是否意味着你可能想要列表中的一些 CheckBox 有样式而一些没有?

标签: .net asp.net vb.net .net-3.5


【解决方案1】:

不明确。您可以使用属性:

ListItem myItem = CheckBoxList1.Items[itemIndex];
myItem.Attributes["bgcolor"] = "lightblue";

就让每个复选框使用 CssClass 而言,每个 CheckBox 实际上是一个ListItem,并且该类不支持 CssClass。

【讨论】:

    猜你喜欢
    • 2014-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-04
    • 2013-05-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多