gh9
gh9

Reputation: 10703

Form tag not rendering Name element

I have form tag rendering as

<form method="post" action="AdminEditListTest.aspx" id="Form1" name="Form1">

This is legacy code that uses

document.Form1.XXX to manipulate the DOM

there are 100's of pages that do this.

When we upgarded the app it stopped rendering the name attribute

<form method="post" action="AdminEditListTest.aspx" id="Form1" >

I understand that setting the (in the web.config)

 xhtmlConformance = "Legacy"

AND SETTING (in the page itself)

<!DOCTYPE html PUBLIC "-//W3C//ELEMENTS XHTML Legacy Markup 1.0//EN" 
 "http://www.w3.org/MarkUp/DTD/xhtml-legacy-1.mod" >

should force IIS to render the name attributes, but this is not working. Are there any other tricks/tactics I can use to have the name attribute rendered on the form element?

Upvotes: 3

Views: 562

Answers (1)

gh9
gh9

Reputation: 10703

So the solution (in addition to setting the xhtmlConformance = "Legacy" in the web.config

was to also <pages controlRenderingCompatibilityVersion="3.5" /> in the web.config

ASP.NET controls have been modified in the .NET Framework version 4 in order to let you specify more precisely how they render markup. In previous versions of the .NET Framework, some controls emitted markup that you had no way to disable. By default, ASP.NET 4 this type of markup is no longer generated. If you use Visual Studio 2010 to upgrade your application from ASP.NET 2.0 or ASP.NET 3.5, the tool automatically adds a setting to the Web.config file that preserves legacy rendering. However, if you upgrade an application by changing the application pool in IIS to target the .NET Framework 4, ASP.NET uses the new rendering mode by default. To disable the new rendering mode, add the following setting in the Web.config file:

<pages controlRenderingCompatibilityVersion="3.5" />

Source

Upvotes: 3

Related Questions