Subscribe via RSS

XHTML Gotchas With ASP.NET

Filed Under Code

Are you attempting validate your XHTML but it just doesn’t seem to be working with ASP.NET? Here are 3 gotchas:

1. xhtmlConformance is not set in web.config

Even if you declare a page to run as Strict, ASP.NET will still render all pages and controls under its default mode Transitional. In order to tell ASP.NET to render controls under Strict, simply add a xhtmlConformance tag in your web.config file.

<xhtmlConformance mode="Strict" />

2. Ensure you have a DOCTYPE

When setting up a new page, it is common (for me at least) to accidentally remove this declaration. Double checking that your DOCTYPE declaration exists is a commonly overlooked gotcha.

<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN>

3. Add a w3cvalidator.browser file to App_Browsers

By default ASP.NET does not recognize the user agent for the W3C Validator service. As a result, pages and controls are not rendered under the XHTML conformance that you set. This again, is an easy fix. Simply download a w3cvalidator.browser and place it in your App_Browsers folder.

Yahtzee! You should be able to validate your page now. If not, more information on web standard fundamentals using ASP.NET can be found over on the MSDN website.

RSS Icon

  Don't miss a drop! Subscribe now via RSS or email.


2 Responses to “XHTML Gotchas With ASP.NET”

  1. » Siti accessibili con 2.0 on September 28th, 2007 3:53 am

    […]  Ma non รจ sufficente per passare il Markup Validation Service della Si risolve con una trick. […]

  2. George Helyar on June 11th, 2010 7:25 am

    Very useful, thanks. Solved my validator woes on ASP.NET 2.0. I had even filed a bug report thinking it was a problem with the validator.

Max Pool - © 2024 - {codesqueeze}. Sycorr Banking Solutions