日期:2014-05-17  浏览次数:20368 次

table使用runat=server后CSS丢失的问题
一个table,列有CSS,本来是好的。
使用了runat="server"运行后,CSS就不行了,查看源文件发现<col class="col1" />这整段都没有了,这是怎么回事?

         <table id="table1" class="tablestyle" runat="server" visible="false">
                <col class="col1" />
                <col class="col2" />
                <col class="col1" />
                <col class="col2" />
                <col class="col1" />
                <col class="col2" />
                     <tr>
                    <td>
                    </td>
                    <td>
                    </td>
                    <td>
                    </td>
                    <td>
                       </td>
                    <td>
                  </td>
                    <td>
                    </td>
                </tr>
            </table>

------最佳解决方案--------------------
MSDN的原话就是
From MSDN "A complex table model is not supported. You cannot have an HtmlTable control with nested caption, col, colgroup, tbody, thead, or tfoot elements."
------其他解决方案--------------------
那就不要给table加runat
如果想要隐藏等可以在外面再加panel
------其他解决方案--------------------
你最好看下页面的源文件,服务器控件生成页面的时候ID会生成成别的。
------其他解决方案--------------------
按我的经验,服务器控件只能用用repeat和简单的一些控件
其他见鬼的东西,微软都会重写id的,很麻烦
------其他解决方案--------------------