Server side HTML table with tbody not compiling in ASP.NET 4.5 [duplicate]

帅比萌擦擦* 提交于 2019-12-11 04:39:40

问题


Possible Duplicate:
How to create thead and tbody in ASP.NET Table?

The following HTML does not compile in an ASP.NET Website

<table runat="server" id="tbl1">
  <tbody>
    <tr>
      <td>
      </td>
    </tr>
  </tbody>
</table>

I get this compilation error:

The best overloaded method match for ‘System.Web.UI.HtmlControls.HtmlTableRowCollection.Add(System.Web.UI.HtmlControls.HtmlTableRow)’ has some invalid arguments
  • This error started appearing after I installed VS2012 and .NET 4.5
  • It occurs in both VS2012 and VS2010
  • It appears in ASP.NET Website project template, the code compiles fine in ASP.NET WebApplication project template
  • The error disappears when removing the "runat" attribute OR the "tbody" tag
  • The weird thing is that the project fails to compile but publishes successfully without errors
  • The page renders correctly in the browser
  • If I uninstall VS2012 and .NET 4.5 the same code works again in VS2010

Update:

I'm not sure why this question was closed in the first place, it wasn't a duplicate. Anyway, Microsoft has acknowledged this as a bug and is working on a fix. More info here


回答1:


You might want to try :

  <table id="yourId" runat="server">
     <thead>
         .
         .
         .
     </thead>
      <tbody>
          <tr>
             <td>
             </td>
          </tr>    
            </tbody>
  </table>


来源:https://stackoverflow.com/questions/12243755/server-side-html-table-with-tbody-not-compiling-in-asp-net-4-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!