Delphi 8 ASP.NET and invalid formatting

Posted: (EET/GMT+2)

 

If you are creating ASP.NET web applications with Delphi 8, it is very likely that you want to have your ASP.NET pages in XHTML format instead of plain HTML.

In XHTML, you need to be much more careful how you align tags and elements, and also make sure all attributes are enclosed in quotation marks, and so on.

Now, Delphi 8's default HTML code formatter tends to create more HTML-like code than XHTML. Especially if you have a ready-made XHTML file, Delphi 8 will modify your page source so that the page isn't valid XHTML code anymore.

As you can imagine, this is very annoying! Luckily, Diamondback ("Delphi 9") is much better in this respect (verified), but still, you can configure Delphi 8 to work the way you want.

To do so, go to Delphi's options dialog box, and browse to the "HTML Tidy Options" section. Make sure you enable HTML Tidy ("Use HTML Tidy as...").

By enabling this option, you disable Delphi 8's default formatter, and you are much better with your existing XHTML code!

To further tune HTML Tidy, make sure you set the "Generated output type" setting to "XHTML".