【问题标题】:How can I apply a CSS class to HtmlTableCell?如何将 CSS 类应用于 HtmlTableCell?
【发布时间】:2010-11-17 07:18:52
【问题描述】:

我正在使用 WebForms。 HtmlTableCell 没有 CssClass 属性。我可以这样做:

<td class="whatever"></td>

但不是这个:

myTableCell.Class = "whatever";

如何将 CSS 类应用到我的 HtmlTableCell

【问题讨论】:

    标签: c# webforms


    【解决方案1】:

    知道了。

    myTableCell.Attributes.Add("class", "whatever");
    

    【讨论】:

    • 它一直都在,盯着我的脸。自Attributes 以来,我要做的一个小改动(基本上)是Dictionary&lt;string,string&gt;,我更喜欢这种形式:myTableCell.Attributes["class"] = "whatever";
    【解决方案2】:

    Attributes 属性也适用于 CSS 样式。

    例如:

    myTableCell.Attributes.Add("style", "height: 30px; border: 1px solid;")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-03
      • 2014-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-18
      • 2014-01-14
      相关资源
      最近更新 更多