这与此问题Why does firebug add <tbody> to <table>?完全相反,可能最终得到相同的答案,但我想确认一下。
我的代码中有一个colgroup,当我使用Firebug或IE调试工具时,它就会消失。见下图。
我的代码
Firebug中的来源
答案 0 :(得分:1)
以下问题Table caption does not show when it is runat=server解释了
不支持复杂的表模型。你不能拥有嵌套标题,col,colgroup,tbody,thead或tfoot元素的HtmlTable控件。这些元素在没有警告的情况下被删除,并且不会出现在输出HTML中。 MSDN
当我创建following HTML
时<table border="1">
<colgroup>
<col span="2" style="background-color:orange"></col>
</colgroup>
<tr>
<td>column 1</td>
<td>column 2</td>
<td>column 3</td>
</tr>
</table>
colgroup/col
代码仍然存在
我最好的猜测是,因为你的表标签是使用runat =“server”,所以C#解析器必须将其删除。您可以通过查看发送到客户端的实际HTML源来证明,即使用“查看源代码”而不是查看生成的DOM。
我无法忍受这种混合服务器和客户端代码为我编写HTML的原因之一....