Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iframe parser error (HtmlIframe/HtmlGenericControl) but still using .NET 4.0 (not .NET 4.5)

Here's my error message

Parser Error Message: The base class includes the field 'iframeShim', but its type (System.Web.UI.HtmlControls.HtmlGenericControl) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlIframe).

Source Error:

Line 180:    <iframe runat="server" id="iframeShim" frameborder="0" scrolling="no" style="position: absolute;
Line 181:        display: block; z-index: 990; z-index: 990" src="~/blank.html"></iframe>

and I'm using .NET 4.0

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34249

and the designer code is:

protected global::System.Web.UI.HtmlControls.HtmlGenericControl iframeShim;

The searches I've done show that this is typically an error when you upgrade to .NET 4.5 and the type of the server side variable hasn't been updated properly (needs to be HtmlIframe, not HtmlGenericControl). Also, those searches have the Parser Error Message slightly different (which makes sense when running in 4.5) - their message is:

... but its type (System.Web.UI.HtmlControls.HtmlIframe) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlGenericControl).

My targetFramework in web.config is:

<compilation targetFramework="4.0">

So, I'm not exactly sure what is going on here. Any ideas? Note, I've installed VS2012 and just recently had to go back to the VS2010 project and do some work in it and this started to happen. I immediately thought it was a .NET versioning issue, but everything still shows I'm using .NET 4.0 in this VS2010 project.

like image 290
Ed Sinek Avatar asked Oct 05 '15 23:10

Ed Sinek


People also ask

Why is my iframe server control being treated as a htmliframe control?

This causes the ASP.NET compiler to treat the IFRAME server control as a HtmlIframe control. This can cause a problem if the Web Forms code behind control variable is still an HtmlGenericControl. The error you see is like this:

How do I fix the parser issue when loading an iframe?

We have recently upgraded all of our WebForms projects to .NET 4.5, and encountered a parser issue when loading pages with an iFrame element. We have corrected this by converting of the iFrame from HtmlGenericControl to HtmlIframe. This has corrected all of the parser errors when we run our code locally.

Why are my iframe variables not working in web forms?

The basic problem is an incompatibility between the object generated from your Web Forms IFRAME server control by the ASP.NET compiler (which compiles ASPX and ASCX files to C# or VB code) and the type of the variable corresponding to that control in your Web Forms code behind.

Is the field 'frame' available in the iframe class?

The base class includes the field 'frame', but its type (System.Web.UI.HtmlControls.HtmlGenericControl) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlIframe). The solution to the previous error is to update the type of the server control variable that corresponds to the IFRAME server control.


1 Answers

Another person had the same issue as I did and it was resolved in this post: https://stackoverflow.com/a/21707234/156611

Basically, make sure your compilation targetFramework is set to 4.6.1 (or whatever you are using) and then go into your ASPX/ASCX file throwing the error and save it. The saving will re-create the designer file with the appropriate type.

in my case, it changed from:

System.Web.UI.HtmlControls.HtmlGenericControl

to:

System.Web.UI.HtmlControls.HtmlIframe
like image 182
Ed Sinek Avatar answered Oct 07 '22 15:10

Ed Sinek