Image button found guilty of not being valid xhtml horror!!!

The .net image button seems so innocent but a trip over to w3c.org and the html validator soon exposes the terrible truth. Prepare yourself for this, sit down, have a large brandy ready… It renders border=”0″ even though you haven’t put one in there yourself! try it! Put any xhtml 1.0 transitional site into the validator:

http://validator.w3.org/

And watch in utter horror while your site is rejected as a bad example to kids everywhere.

So what is going on here? And is there anyway out?

Well after some digging I found an excellent article:

http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/ac098c63-61ff-4b53-b5ad-72cb2eb0f7f2

It turns out the validator is unrecognised as a browser type to asp.net and so is presented with html 4.0 instead of xhtml, hence the border=”0″ debarkle.

Is there a workaround? Yes there is either don’t use image buttons or put this in your web.config:

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

A solution to a weird problem, but necessary if like me you want that green tick 🙂

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter
Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

No Responses to “Image button found guilty of not being valid xhtml horror!!!”

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Website:
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Content

Stay in contact!

Email Dave Riley
Dave Riley's Linkedin Profile
Dave Riley's Facebook Profile
Dave Riley's Twitter Profile
Dave Riley's Plaxo Profile