4

After upgrading an ASP .Net project from .Net 4.0 w/ Visual Studio 2010 to .Net 4.5 with Visual Studio 2012, the JavaScript code on certain pages stopped working. This was because the "name" attribute on some element (for example, form elements) was no longer being rendered to the browser.

Even though the following section is still int the web.config file, the "name" attribute is suppressed:

<xhtmlConformance mode="Transitional"/>

What could cause this behavior to change?

BrianCooksey
  • 1,543
  • 1
  • 12
  • 19

1 Answers1

5

This problem is caused by the change the upgrade process makes to another section of the web.config file.

As it turns out, the decision to render the name attribute is also controlled by the controlRenderingCompatibilityVersion attribute in the pages element of the web.config file.

During the process of upgrading the solution/project, the value

controlRenderingCompatibilityVersion="3.5"

is updated to

controlRenderingCompatibilityVersion="4.0"

The .Net Framework code which checks xhtmlConformance also checks controlRenderingCompatibilityVersion. A version of 4.0 or greater trumps the "mode" attribute setting of xhtmlConformance. (for example in the the System.Web.UI.HtmlControls.HtmlForm class's RenderAttributes method)

BrianCooksey
  • 1,543
  • 1
  • 12
  • 19
  • Microsoft's repsonse to this Connect bug confirms that the setting is automatically changes during upgrade: http://connect.microsoft.com/VisualStudio/feedback/details/781706/net-4-5-rendering-issues-in-ie – BrianCooksey Jun 10 '13 at 20:54
  • Why you don't accept your answer? It seems to be correct (at least in my case). – IvanH Sep 25 '13 at 11:47
  • This was driving me crazy. Thanks a lot! – Francisco Jun 24 '15 at 20:42