XHTML Validation Fails due to <asp:ImageButton> renders a BORDER="0" output

Steps to Reproduce: <%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ImageButton ID="flag_it" runat="server" style="width:22px;border:thin inset silver;vertical-align:middle;" ImageUrl="images/italiano.jpg" />
<asp:ImageButton ID="Iflag_en" runat="server" BorderWidth="0" style="width:22px;vertical-align:middle;" ImageUrl="images/uk.jpg" />
</div>
</form>
</body>
</html>
Actual Results: This page is not Valid XHTML 1.0 Transitional!

Line 12, column 81: there is no attribute "border" .
...it" src="images/italiano.jpg" border="0" style="width:22px;border:thin inset

Expected Results: XHTML 1.0 Transitional validation

Web.Config

< xml version="1.0" >
<configuration>
<system.web>
</system.web>
</configuration>

Hi everybody,
*server running IIS5 and ASP.NET 2.0
*Very silly example file.
*Very (really..) simple web.config file
Nevertheless I keep on getting wrong XHTML output, not complying with W3C specifications

I submitted the issue to Microsoft but they just replyied:
Resolved as Not Reproduced by Microsoft

not really helpful indeed...

What it is really remarkable is that:

1) viewing page source, the tag BORDER="0" does not exist...
2) while submitting same page to http://validator.w3.org
the "infamous" tag magically appears..

That is quite strange.. I understand. In any case I do need to have website validated...

Everybody can try by him/herself
please surf to
www.appenninogenovese.it/default3.aspx
that is the example page

have a look at source code... (NO Border="0")
and then try to submit same page to http://validator.w3.org (invalid Border="0" added...)

This page is not Valid XHTML 1.0 Transitional!

mumble...


Answer this question

XHTML Validation Fails due to <asp:ImageButton> renders a BORDER="0" output

  • dougzhoez

    There is actually a thrid option.

    You could define the "browser capabilities" of the W3C validator in web.config under the system.web section. Below is the code from my web.config file.

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

    -Mike


  • MandiG

    Michael, how do you know what to "match" in the browserCaps I need the same solution for when validating the CSS of my aspx page via the W3C CSS validator (http://jigsaw.w3.org/css-validator/)
  • Error installing SSIS

    The match compares the HTTP Header User-Agent string against a regular expression string.  To find out the User-Agent of the W3C CSS validator first setup IIS logging to save the User-Agent.  Then run the W3C CSS validator so that an item will be put into the logs then open the current log to find the User-Agent string.  

    I have already done this and the W3C CSS validator User-Agent is:
    Jigsaw/2.2.5+W3C_CSS_Validator_JFouffa/2.0.

    I would probably setup my regular expression as:
    <case match="W3C_(CSS_) Validator">

    This way you need only one case for the XHTML and CSS validators.

    -Mike


  • storm80y

    Finally, 1 month later I received the correct workaround from Microsoft support.
    It seems to be a sort of misunderstanding between W3C validator and ASP.NET that can be resolved (for validation purposes) as follows.

    "You should be able to view the source of the page in Internet Explorer by choosing "Source" from the browser's "View" menu.

    As you can see above, the source being generated in XHTML compliant. You're seeing otherwise, of course, but that is likely to be because you are attempting to request the page using the W3C's validator instead of a desktop browser. Because the W3C validator returns a User-Agent header that isn't recognized by ASP.NET, content appropriate for older browsers that should be compliant with HTML 4.0 Transitional -- but not necessarily any of the XHTML language flavors -- will be generated.

    There are a few options available to you if you need to validate your content using the W3C's validator service, you have a couple options:

    1. You could use the "Source" item in the browser's "View" menu to view the source in Notepad, save that file locally, and then upload it to the W3C's Validator service for validation using the file upload interface.
    2. You could change the "ClientTarget" attribute on your page's Page directive to always generate uplevel content."


    The second, of course, is the only practical workaround if you need to certify the website for direct online validation on W3C validator.
    So just enter ClientTarget="uplevel" in your page's Page directive and everything will be allright.

  • XHTML Validation Fails due to <asp:ImageButton> renders a BORDER="0" output