VS 如何自动生成 aspx.designer.cs文件内容(解决"The base class includes the field ''"错误)

转自: http://support.microsoft.com/kb/941824

SYMPTOMS
Consider the following scenario: You create a Microsoft ASP.NET 2.0 Web applicat...

<script type=text/javascript> loadTOCNode(1, 'symptoms'); </script>
Consider the following scenario:
  • You create a Microsoft ASP.NET 2.0 Web application.
  • You add markup that resembles the following to the Web page.
    <body>
    	<form id="form1" runat='server">
    		<Table ID="Tablename" runat="server" Height="224px" Width="399px">
    			<tbody ID="tbodyname" runat="server"></tbody>
    		</Table>
    	</form>
    </body>
    
  • You build the application by using Microsoft Visual Studio 2005.
  • You install the Microsoft .NET Framework 3.5.
  • You open the project in Visual Studio 2005 and then build the application.
In this scenario, you receive an error message that resembles the following:
ASP.NET runtime error: The base class includes the field ‘ tbodyname’, but its type (System.Web.UI.HtmlControls.HtmlGenericControl) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlTableBodySection).

CAUSE
In the .NET Framework 3.5, the following HTML tags no longer map to the HtmlGene...

<script type=text/javascript> loadTOCNode(1, 'cause'); </script>
In the .NET Framework 3.5, the following HTML tags no longer map to the HtmlGenericControl class:
  • tbody
  • thead
  • tfoot
In the .NET Framework 3.5, these tags map to the following classes:
Collapse this table Expand this table
TagClass
tbodyHtmlTableBodySection
theadHtmlTableHeaderSection
tfootHtmlTableFooterSection
This change enables the layout options of the new ListView control.

Note When you install the .NET Framework 3.5, the .NET Framework files in the V2.0.50727 folder are updated. Therefore, when you install the .NET Framework 3.5, Visual Studio 2005 is affected.

RESOLUTION
To resolve this problem, update the Web page so that the HTML tags map to the ne...

<script type=text/javascript> loadTOCNode(1, 'resolution'); </script>
To resolve this problem, update the Web page so that the HTML tags map to the new classes. You can do this manually. Or, you can use the Visual Studio 2005 designer to do this automatically.

Manual method

<script type=text/javascript> loadTOCNode(2, 'resolution'); </script> To manually resolve this problem, follow these steps:
  1. In Visual Studio 2005, open the PageName.aspx.designer.cs file.

    Note The placeholder PageName represents the name of the Web page on which you encounter the problem.
  2. Locate the entries for the tbody, thead, and tfoot tags.
  3. Change the entries to map these tags to the new classes. For example, make the following changes.

    Old entry
    protected global::System.Web.UI.HtmlControls.HtmlGenericControl tbodyname;
    New entry
    protected global::System.Web.UI.HtmlControls.HtmlTableBodySection tbodyname;
  4. Save the PageName.aspx.designer.cs file.

Automatic method

<script type=text/javascript> loadTOCNode(2, 'resolution'); </script> To automatically resolve this problem by using the Visual Studio 2005 designer, follow these steps:
  1. In Visual Studio 2005, open the PageName.aspx file.

    Note The placeholder PageName represents the name of the Web page on which you encounter the problem.
  2. In the Source window, locate the <table> and </table> tags, and then select all entries in the range that includes these tags.
  3. On the Edit menu, click Cut. This operation removes the corresponding entries from the PageName.aspx.designer.cs file.
  4. Keep the cursor in the same location.
  5. On the Edit menu, click Paste. This operation adds the entries that inherit the new classes back to the PageName.aspx.designer.cs file.
  6. Save the PageName.aspx file.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值