我正在将一个大型网站项目从Visual Studio 2010升级到2012。在我的整个项目中,我都有具有table
属性的runat="server"
元素。其中许多内部都有thead
元素。当我在2012年打开它并尝试进行构建时,出现以下错误:
Value of type 'System.Web.UI.HtmlControls.HtmlGenericControl' cannot be converted to 'System.Web.UI.HtmlControls.HtmlTableRow'
删除
runat="server"
属性或注释掉thead
可以解决此问题。仅注释掉tr
内部的thead
元素不能解决该问题。这是重现该问题的简化示例:<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table id="Example" runat="server">
<thead>
<tr>
<th>test</th>
</tr>
</thead>
</table>
</div>
</form>
</body>
</html>
错误出现在
table
元素打开的位置。不执行以下任一操作,如何解决此问题?
删除
runat="server"
属性删除
thead
元素将其更改为
asp:table
元素奖励解释2012年所做的不同工作的人。
更新:
在Web应用程序中,仅在网站中不会发生此问题。
实际上,该项目不是我的开发环境,而是真正的升级。在两种情况下,我都使用4.0框架
我尝试使用4.5框架,但没有帮助。
2012年9月10日:
我有微软支持的公开案例。他们的开发团队正在对此进行研究。
2012年10月24日:
由于.NET 4.5取代了4.0,因此我也无法在VS 2010中进行编译。我遇到的问题纯粹是.NET,而不是Visual Studio。
最佳答案
现在可以解决此问题。
Windows 8的http://support.microsoft.com/kb/2750149和Windows 7平台的http://support.microsoft.com/kb/2750147。
关于asp.net - 如何在runat =“server”表元素中包含thead?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12148825/