【发布时间】:2010-11-17 07:18:52
【问题描述】:
我正在使用 WebForms。 HtmlTableCell 没有 CssClass 属性。我可以这样做:
<td class="whatever"></td>
但不是这个:
myTableCell.Class = "whatever";
如何将 CSS 类应用到我的 HtmlTableCell?
【问题讨论】:
我正在使用 WebForms。 HtmlTableCell 没有 CssClass 属性。我可以这样做:
<td class="whatever"></td>
但不是这个:
myTableCell.Class = "whatever";
如何将 CSS 类应用到我的 HtmlTableCell?
【问题讨论】:
知道了。
myTableCell.Attributes.Add("class", "whatever");
【讨论】:
Attributes 以来,我要做的一个小改动(基本上)是Dictionary<string,string>,我更喜欢这种形式:myTableCell.Attributes["class"] = "whatever";。
Attributes 属性也适用于 CSS 样式。
例如:
myTableCell.Attributes.Add("style", "height: 30px; border: 1px solid;")
【讨论】: