7

I have a web site i created using VS2012 web edition,

Running a VB.net asp web site,

In the VS2012 debug/release mode it compiles and everything works good, When i upload it to a server (Windows server 2008 R2) I get the following error:

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


Line 2:  
Line 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Line 4:  <html id="html" xmlns="http://www.w3.org/1999/xhtml" dir="ltr" runat="server">
Line 5:  <head id="Head1" runat="server">
Line 6:    <title></title>

I looked a bit on the web and found this : VS 2010: Value of type 'System.Web.UI.HtmlControls.HtmlGenericControl' cannot be converted to 'System.Web.UI.HtmlControls.HtmlTableRow'

Installed it but no help,

The site i created was re-created from another vb.net project so i used a web.config with from the old one, maybe it has something to do with it, i have no "assembly" properties it this XML.

Other pages that are not related to that master page (that html tag is running on a master page...) work's fine.

Community
  • 1
  • 1
Matan L
  • 997
  • 3
  • 14
  • 35
  • Perhaps, running different version of .net framework on deployment server? – T.S. Oct 21 '13 at 21:32
  • nope... checked that... – Matan L Oct 22 '13 at 08:39
  • tried to run this website on a different cloud to verify that this is not a server config settings so i used the azure websites service, same error... – Matan L Oct 22 '13 at 21:59
  • Is this a Web Site project, or a Web Application project? – Michael Liu Oct 23 '13 at 19:17
  • Can you post the entire page code please – Brian Ogden Oct 23 '13 at 19:49
  • its a website project – Matan L Oct 23 '13 at 20:32
  • Are you testing it in IIS7.5 on Windows 7 (the client version of Windows which corresponds to WS2008R2)? If you suspect the web.config file has something to do with it, have you compared your one to a default one from VS2012 running on IIS7.5? Which .NET framework version are you using? – Andrew Morton Oct 23 '13 at 20:33
  • Have you tried giving the tag an id which is not "html", e.g. "html99"? – Andrew Morton Oct 23 '13 at 20:40
  • VS 2012 and Windows Server 2008 R2. What framework are you targeting? Seems like I ran into issue (that escapes me right now) with 4.5 on this OS. When I changed it to target 3.5, it was OK. Also moved to a test server runing Server 2012 and it was OK. Seems like I finally found a MS post that said they were not compatable. – Steve Oct 23 '13 at 22:09
  • Maybe related? http://stackoverflow.com/questions/12148825/how-do-i-include-thead-in-a-runat-server-table-element – the_lotus Oct 24 '13 at 19:18
  • As i said, i tried to run this on windows azure website also (belongs to microsoft and runs the most updated software...) and got the same error... – Matan L Oct 25 '13 at 16:41
  • Could it be namespace conflict issue? – Poornima Oct 29 '13 at 20:22
  • Simply import in your code behind file :`using System.Web.UI.HtmlControls`. – Dungeon Dec 20 '18 at 05:32

4 Answers4

6

OK,

So after trying a lot of stuff that didnt work i found a solution, i dont like this solution but it works,

I went to the page.designer.vb file, and then looked for the 'html' and 'Head1' properties that were generated there,

In there i replaced their types to System.Web.UI.HtmlControls.HtmlGenericControl

Afterwards, it worked.

Weird bug, nothing else (including the "hot fixes" that are mentioned in other posts helped.

Hope this would help some one out there .

Matan L
  • 997
  • 3
  • 14
  • 35
  • Did you managed to find why behavior is different on server and in VS? – IvanH Oct 30 '13 at 18:34
  • FYI: I just had to do this as well in a C# app. Thank you - saved me some serious time! – Edward Jul 28 '15 at 21:16
  • What I did to fix this is right click the solution>clean, then I deleted the bin folders under my projects and rebuilt the solution. From my understanding you shouldn't manually edit the *designer.cs files so I wanted to add this here. I know this is an old thread but since I ended up here someone else might too. – NetworkMonkey Jun 12 '18 at 14:24
1

Somehow the designer file and the markup file get out of sync, even if the types appear to match.

I changed the ID attribute of the problematic control, saved, and rebuilt in the markup file. I then changed it back to the original ID, saved, and rebuilt.

Problem goes away!

taylorsabell
  • 664
  • 5
  • 15
  • happened to me because i was using 2 different IDEs at the same time. all i did was closed the other one and opened the solution with visual studio and saved the aspx design file. it auto generated the designer.cs and it all went fine after that. – Niklas Apr 26 '20 at 05:25
0

Weird issue it is I am not sure if there is a proper solution for this but what worked for me was simply changing the Control ID. and then designer.cs file was changed and all worked good.

Jamshaid K.
  • 3,555
  • 1
  • 27
  • 42
0

I fixed it by Cleaning Solution/project -> Rebuild

General Grievance
  • 4,555
  • 31
  • 31
  • 45