Yesterday I got the following error:
Parser Error Message: The base class includes the field ‘IFrame’, but its type (System.Web.UI.HtmlControls.HtmlIframe) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlGenericControl).
Source Error:
Line 14: <iframe id=”IFrame” frameborder=”0″ runat=”server” visible=”false”/>
Reason:
The code was written using .NET 3.5 but executed in the .NET 4.5 runtime. From .NET 4.5, Microsoft decided to change the iframe from a HtmlGenericControl to its own control, a HtmlIframe.
They did this with a wide range of controls for example System.Web.UI.HtmlControls.HtmlTableCell and System.Web.UI.HtmlControls.HtmlAnchor.
Solution:
You need to recompile the code using the .net 4.5 runtime.
And when doing this, you need to change the *.designer.cs file reference from:
protected global::System.Web.UI.HtmlControls.HtmlGenericControl IFrame;
To:
protected global::System.Web.UI.HtmlControls.HtmlIframe IFrame;
A bug has been reported that the VS2012 does not make this change itself, but all I had to do was to rename the ID of the IFrame control, and VS figured it out for me.
More information:
Thank you. This was very helpful.
LikeLike
Hi, great post. But I still run into this issue (see here http://stackoverflow.com/questions/20060196/adding-attribute-to-html-tag-via-code-behind-results-in-error-type-system-web-u)
For me the code does run locally but not on production. Where do I see which.NET version my code was built against and which .NET version I run against? Thanks!
LikeLike
Perfect! had exactly this problem
LikeLike
Nice. Thank You.
LikeLike
Thanks You…
LikeLike
Pingback: Using iframe on a Custom SharePoint Layout Page (with bootstrap responsive embed) – All about SharePoint by Shu Jackson
The below update to the web.config worked for me when migrated from 3.0 to 4.5.
LikeLike
Thank you soon much…saved my time..
LikeLike