简体   繁体   中英

Rendering htm tag in C#

Hi and thanks in advance for reading.

Recently, I upgraded my application from .net2 to .net 4.5. Everything works fine except the top htm control

"<html runat="server" id="pageHtm">

Running the appplication, I get this weird parser error:

The base class includes the field 'pageHtml', but its type (System.Web.UI.HtmlControls.HtmlElement) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlGenericControl).

After a lot of tries, I got that this is a known bug and the solution is a patch by Microsoft. However, the problem still exists even after installing the patch.

To resolve this problem, follow these steps:

  1. 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;

Save the PageName.aspx.designer.cs file.

To automatically resolve this problem by using the Visual Studio designer, follow these steps:

1.In Visual Studio 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 and 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.

Keep the cursor in the same location.

4.On the Edit menu, click Paste . This operation adds the entries that inherit the new classes back to the PageName.aspx.designer.cs file.

Save the PageName.aspx file.

Answer above is a general solution but your case

open your designer file of your page in solution explorer and change all of

System.Web.UI.HtmlControls.HtmlElement

to

System.Web.UI.HtmlControls.HtmlGenericControl

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM