ASP.NET and XHTML
Posted in Design
An MSDN article ASP.NET and XHTML talks about conformance of server controls with XHTML, markup validation, changes to rendering logic between HTML and XHTML, changing page MIME type, and other interesting points.
One thing that I still can’t make peace with is that markup can be rendered in one of three modes:
- Legacy (which is similar to how markup was rendered in previous versions of ASP.NET)
- Transitional (XHTML 1.0 Transitional)
- Strict (XHTML 1.1)
This brings me to the same point: where do HTML 4.01 Strict, HTML 4.01 Transitional and XHTML 1.0 Strict fit in?
Obviously, what DOCTYPE is declared in markup is of little meaning to server controls, and I assume they rely on the <xhtmlConformance> section to figure out how to render themselves. If I configure XHTML conformance to a strict mode, which xxxxx Strict am I getting? In other words, I want HTML 4.01 Strict, will the output be coerced to XHML 1.1 Strict? That’d be wild!
I guess I need to put together some test cases and see for myself. So far I just don’t get it.
5 comments
scottgu
on November 30, 2005
The actual rendered is up to the developer (ASP.NET doesn't control this -- it is specified in the .aspx page and can be set to whatever the developer wants).
ASP.NET 2.0 controls do then render in one of three markup output modes:
Legacy
XHTML Transitional
XHTML Strict
You can configure which ones you want and it will restrict itself to outputing the default controls in that markup format.
I believe you should be able to set an HTML 4.01 strict doctype, and then configure the controls to render to an XHTML Transitional (or strict) sub-set and still be HTML 4.01 valid and compliant.
Hope this helps,
Scott
Stefan
on December 3, 2005
The output code is valid if you use
Now ASP.NET recognizes the validation-engine and your page validates. There's nothing more to it. I still hope Microsoft takes care of this with a future update so that no extra code or files are nessesary to get valid output. For now I think this is the best solution to get valid output easily without effecting the site performance.
inoodle
on December 4, 2005
From my (brief, slightly drunken:) tests, its seems like html 4.01 strict isn't an option. The problem being the id names being __EVENT... etc.
Surely this can't be right though... I'll stagger on a bit more...:)
Shannon J Hagere
on December 4, 2005
My guess:
I use xhtml 1.0 transitional because I simply can't use strict. If I were able to use strict, I would hopefully use 1.1 strict. And "legacy" sums up all the people still using old calendars... ;)
Just a guess, but the 3 choices make sense to me.

Chris Lienert
on November 28, 2005
I held out hope that doctype target rendering would be good in v2 and, like you, I'm greatly disappointed with the limited options available.
I guess I'll have to continue with custom control rendering...