by Mads Kristensen
25. April 2006 06:12
If you ever tried to validate a web page to the W3C standards you might have experienced
some differences between the code that is generated to your browser and the code that
the validators see. That's because ASP.NET renders the page differently for newer
browsers and older browser. The validator is considered an old browser and is therefore
presented with legacy code from the server controls.
An ImageButton control renders a border attribute (border="0") when in legacy/old
mode and a style attribute when in strict/new mode (style="border-width:0px;"). If
your page's DOCTYPE is XHTML strict, the border attribute is not allowed and your
page doesn't validate because of that.
While browsing the web.config documentation at MSDN, I stumbled upon a switch that
overrules this different rendering. If you are sure you always want the server controls
to be rendered in strict/new mode, just add this element to the web.config's <system.web>
section:
<xhtmlConformance
mode="Strict" />
I do not understand why the ASP.NET 2.0 compiler doesn't look in the DOCTYPE for this
information. By adding the above code to the web.config you are telling ASP.NET the
same information twice, which is bad.
* Only $4.95/month ASP.NET & Windows 2008 + IIS 7 Hosting! FREE SQL Included
5cbc5842-cff6-4705-9ad0-c2d2ea876d03|0|.0
Tags:
ASP.NET