Wednesday, June 06, 2007

XHTML validation

Yeah, I know it is a pain. It is like flossing, good to do, but not something you want to do.

Using the w3c validator, http://validator.w3.org/ allows for viewing all of the problems, but I encountered one recently that I couldn't figure out how to fix.

I had an asp:ImageButton which rendered out with a border="0" which the validator would flag. I couldn't seem to get rid of the border= (it was being automatically added by .NET)

It turns out that the validator doesn't return an appropriate User-Agent header (viewing the source in IE would show no border="0").

By putting an entry into your web.config you can have the validator get the correct html from the server:

Under <system.web>

<browserCaps>
<case match="W3C_Validator*">
TagWriter = System.Web.UI.HtmlTextWriter
W3CDomVersion = 1.0
</case>
</browserCaps>

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home