与COL,COLGROUP,TBODY和THEAD HTML表格标记抛出在Visual Studio 2010和Visual Studio 2012编译出错 [英] HTML table tag with col, colgroup, tbody, and thead throws compile error in Visual Studio 2010 and Visual Studio 2012

查看:447
本文介绍了与COL,COLGROUP,TBODY和THEAD HTML表格标记抛出在Visual Studio 2010和Visual Studio 2012编译出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET 3.5的网站,其中包含COL,COLGROUP,TBODY和THEAD标签表标签。这是带有runat =server属性的服务器端的标签。该表工作正常在Visual Studio 2010,但在我安装了Visual Studio 2012和.NET 4.5,这个标签现在失败的Visual Studio 2010和Visual Studio的2012年编译(我想两者兼而有之。)以下是编译器错误被抛出:

I have a .NET 3.5 web site with a table tag that contains col, colgroup, tbody and thead tags. This is a server side tag with the runat="server" attribute. This table was working fine in Visual Studio 2010, but after I installed Visual Studio 2012 and .NET 4.5, this tag now fails to compile in Visual Studio 2010 and in Visual Studio 2012. (I tried both.) Here are the compiler errors that are being thrown:

      
  • 的最佳重载方法匹配'System.Web.UI.HtmlControls.HtmlTableRowCollection.Add(System.Web.UI.HtmlControls.HtmlTableRow)'   有一些无效参数
  •   
  • 参数1:无法从System.Web.UI.HtmlControls.HtmlGenericControl转换   System.Web.UI.HtmlControls.HtmlTableRow
  •   
  • The best overloaded method match for 'System.Web.UI.HtmlControls.HtmlTableRowCollection.Add(System.Web.UI.HtmlControls.HtmlTableRow)' has some invalid arguments
  • Argument '1': cannot convert from 'System.Web.UI.HtmlControls.HtmlGenericControl' to 'System.Web.UI.HtmlControls.HtmlTableRow'

下面就是我的工作有一个例子:

Here's an example of what I'm working with:

<table id="TestTable" runat="server">
    <colgroup>
        <col width="30%" />
        <col width="70%" />
    </colgroup>
    <thead>
        <tr>
            <td>Sample header 1</td>
            <td>Sample header 2</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Sample cell 1</td>
            <td>Sample cell 2</td>
        </tr>
        <tr>
            <td>Sample cell 3</td>
            <td>Sample cell 4</td>
        </tr>
    </tbody>
</table>

有谁知道如何解决这个问题,这样我们就可以得到网站编辑和继续工作?

Does anyone know how to fix this problem, so that we can get the site to compile and continue working?

推荐答案

这似乎是以后的Visual Studio 2012和.NET 4.5的安装无证重大更改的网站。我无法找到引用这个由Microsoft,记录了.NET 4.5的变化:<一href="http://msdn.microsoft.com/en-us/library/hh367887.aspx">http://msdn.microsoft.com/en-us/library/hh367887.aspx

This appears to be an undocumented breaking change for web sites after the install of Visual Studio 2012 and .NET 4.5. I am not able to find references to this in the .NET 4.5 changes documented by Microsoft: http://msdn.microsoft.com/en-us/library/hh367887.aspx

研究问题后,下面似乎可以解破表的标签。

After researching the problem, the following appear to be possible solutions to the broken table tag.

  1. 卸载Visual Studio 2012和.NET 4.5。参考:<一href="http://stackoverflow.com/questions/12243755/server-side-html-table-with-tbody-not-compiling-in-asp-net-4-5">Server用TBODY端的HTML表中未编制在ASP.NET 4.5

我知道这不一定是理想的解决方案,但如果没有低于其他解决方案可以轻松实现,你可能最终没有其它选择。此外,仅仅因为这是第一项,这不是我所建议的主要解决方案。这只是一种选择。

I realize that this is not necessarily an ideal solution, but if none of the other solutions below can be implemented easily, you may end up with no other choice. Also, just because this is the first entry, it is not what I am recommending as the primary solution. It's just an option.

将您的网站变成一个Web应用程序。与RUNAT表=服务器出现编译文件中使用的Web应用程序时。

Convert your web site into a web application. The table with runat="server" appears to compile file when using a web application.

有做这种转换的其他好处,比如更容易编写单元对你的web应用程序中的code测试。但是,您将需要评估涉及从网站转换为Web应用程序的工作,你需要说服你的老板和同事的同事,你需要进行更改。

There are additional benefits to doing this conversion, such as making it easier to write unit tests against the code inside your web application. However, you will need to evaluate the work involved with converting from a web site to a web application, and you will need to convince your bosses and fellow coworkers that you need to make this change.

检查服务器端code(隐藏页/控制code)在桌子上。您是否使用在服务器端code中的控制?如果没有,删除=服务器。该页面然后编译就好了。

Check the server side code (code behind page/control) for the table. Are you using the control in the server side code? If not, remove runat="server". The page then compiles just fine.

<table id="TestTable">
    <colgroup>
        <col width="30%" />
        <col width="70%" />
    </colgroup>
    <thead>
        <tr>
            <td>Sample header 1</td>
            <td>Sample header 2</td>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Sample cell 1</td>
            <td>Sample cell 2</td>
        </tr>
        <tr>
            <td>Sample cell 3</td>
            <td>Sample cell 4</td>
        </tr>
    </tbody>
</table>

  • 您正在使用的服务器端code控制。除去山口和COLGROUP标签和移动的列花式入TD或第表中的第一行的细胞。 (列宽度和花式从第一下表行继承,所以第一单元上设置宽度=40%,例如,使所有的细胞在该列具有宽度=40%。)取出THEAD标签和改变这一切的TD细胞的表TH(表头)细胞。删除TBODY标记。

  • You are using the control in the server side code. Remove the col and colgroup tags and move the column stylings into the td or th cells of the first row of the table. (Column width and stylings inherit from the first row down the table, so setting width="40%" on the first cell, for example, makes all cells in that column have width="40%".) Remove the thead tag and change all td cells in the table to th (table header) cells. Remove the tbody tag.

    <table id="TestTable" runat="server">
        <tr>
            <th width="30%">Sample header 1</td>
            <th width="70%">Sample header 2</td>
        </tr>
        <tr>
            <td>Sample cell 1</td>
            <td>Sample cell 2</td>
        </tr>
        <tr>
            <td>Sample cell 3</td>
            <td>Sample cell 4</td>
        </tr>
    </table>
    

  • 转换为使用&LT; ASP:表&gt; 与标记&LT; ASP:TableHeaderRow&GT; &LT; ASP:的TableRow&GT; 控件。参考:如何创建THEAD和TBODY在ASP.NET表?

  • Convert to using the <asp:Table> tag with <asp:TableHeaderRow> and <asp:TableRow> controls. Reference: How to create thead and tbody in ASP.NET Table?

    这篇关于与COL,COLGROUP,TBODY和THEAD HTML表格标记抛出在Visual Studio 2010和Visual Studio 2012编译出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆