Blog Home  Home Feed your aggregator (RSS 2.0)  
XHTML Validation - Manuel Abadia's ASP.NET stuff
# Wednesday, 31 May 2006

I have been using this HTTP Module for the last 2 weeks and I have to say it is awesome:

Basically, it checks the html generated by the page and displays if it validates against the XHTML mode you're using.

If you use it early in a project to check for XHTML conformance is very easy to keep the pages as compliant as possible. You may be wonder why to use it because Visual Studio checks the HTML generated, but keep in mind that Visual Studio checks the HTML in the ASPX page but not after all the controls have rendered their mark-up. The big surprise is that the ASP.NET TreeView control fails validation (XHTML 1.0 Transitional)! When a TreeView is rendered, some script is injected in the page:




    function TreeView_PopulateNodeDoCallBack(context,param) {



// -->



But the script tag is missing the required attribute "type". It's hard to explain how the testing team overlooked this. I took a look to the CSS Control Adapters found here:

but even if they look good, they are in beta and they are not complete. For example, the SelectedNodeChanged event is not triggered if you use the CSS Control Adapters and some properties like ShowCheckBoxes aren't used when rendering the control). The CSS Control Adapters should be taken as a sample about writting custom adapters.

So for now I have to live with the TreeView bug :(

The validator module is extensible so you can hook in a class that will be called when validation has occured to do whatever you want to do. There is a post about that here that explains how to extend the module to send an email when the validation fails:

I have added to my TODO list an extension to the module that logs errors using the health monitoring system.

Now that we have XHTML validation, what would be really cool is an HTTP Module that does CSS validation. However that's a lot more complicated than XHTML validation.

If anyone has some spare time, the sources for the W3C CSS validator are here:

So with a bit of work that could be rewriten in C# and converted to an HTTP Module.

Wednesday, 31 May 2006 14:42:31 (Romance Daylight Time, UTC+02:00)  #    Comments [1]   ASP.NET  | 
Copyright © 2018 Manuel Abadia. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.