Search code examples
asp.netxhtml-1.0-strict

XHTML 1.0 Strict (or Transitional) compliance in ASP.NET 2.0/3.5


Are there any good methods for getting ASP.NET 2.0 to validate under the XHTML 1.0 Strict (or Transitional) DTD? I'm interested to hear some ideas before I hack up the core of the HTTP response.

One major problem is the form tag itself, this is the output I got from W3C when I tried to validate:

Line 13, Column 11: there is no attribute "name".
<form name="aspnetForm" method="post" action="Default.aspx" onsubmit="javascript

That tag is very fundamental to ASP.NET, as you all know. Hmmmm.


Solution

  • ASP.NET 2.0 and above can indeed output Strict (or Transitional) XHTML. This will resolve your 'there is no attribute "name"' validation error, amongst other things. To set this up, update your Web.config file with something like:

    <system.web>
        ... other configuration goes here ...
        <xhtmlConformance mode="Strict" />
    </system.web>
    

    For Transitional XHTML, use mode="Transitional" instead.

    See How to: Configure XHTML Rendering in ASP.NET Web Sites on MSDN.