As you may know, all components from the r.a.d.controls suite render XHTML 1.1 compliant output. We wanted to promote it in a way that all users can click a button in our online examples and see for themselves that everything validates perfectly. W3C provides an online validation service (http://validator.w3.org) so it should not be that hard. Unfortunately ASP.NET 1.x complies with *NO* HTML standard ever approved by W3C. ASP.NET 2.0 was first XHTML 1.1 compliant, but then in the official release Microsoft fell back to XHTML 1.0 transitional which is less restrictive.
I made a couple of Google searches and found other people who had the same problem. There were different approaches and we picked the one with custom page and regular expression replaces. As a result all live examples inherit from a page derived from System.Web.UI.Page. In the Render method the output is cleaned by a set of regular expressions to comply with the XHTML 1.1 specification. Here are all the problems solved by XhtmlPage:
At the end of this endeavor I really became a regular expression ninja and nothing seemed impossible. However I should give credit to www.regexlib.com and their tester page: http://www.regexlib.com/RETester.aspx - it was really helpful and saved me lots of time to find the right regular expression hack.
However XhtmlPage does not magically cure all bad ASP.NET practices. Developers have to make sure the rest of the html is compliant – lowercase tag names, no unclosed tags. Here I will mention the rather annoying feature of Visual Studio 2002/2003 to capitalize some of the tags when switching between design and source view. It slowed us down a bit. Another thing to mention is that client-side validation controls cannot be made valid using that technique. They deeply rely on custom attributes which fail to validate. However server side validation can be used instead.
If you want to make XHTML compliant pages but cannot switch immediately to ASP.NET 2.0, XhtmlPage is an option. The class is available from the Telerik.QuickStart.dll assembly which can be found in the bin folder of any r.a.d.control. We plan to release the source code soon.
Stefan Rahnev (@StDiR) is Product Manager for Telerik Kendo UI living in Sofia, Bulgaria. He has been working for the company since 2005, when he started out as a regular support officer. His next steps at Telerik took him through the positions of Technical Support Director, co-team leader in one of the ASP.NET AJAX teams and unit manager for UI for ASP.NET AJAX and Kendo UI. Stefan’s main interests are web development, agile processes planning and management, client services and psychology.
Copyright © 2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.