XHTML Gotchas With ASP.NETFiled 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.
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.
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.