Link to home
Start Free TrialLog in
Avatar of rito1
rito1

asked on

W3C Validating an ASP.NET ImageButton control

Hi All,

I am trying to be a good boy and make sure my pages validate correctly via W3C's XHTML validator but what I have found is that the following control:

<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/button_logon.png" PostBackUrl="page2.aspx" />

Viewing this within my browser outputs the following code:

<input type="image" name="ctl00$ImageButton1" id="ctl00_ImageButton1" src="images/button_mi_logon.png" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ImageButton1&quot;, &quot;&quot;, false, &quot;&quot;, &quot;page2.aspx&quot;, false, false))" style="border-width:0px;" />

But the W3C validator sees this output html as:

<input type="image" name="ctl00$ImageButton1" id="ctl00_ImageButton1" src="images/button_mi_logon.png" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ImageButton1&quot;, &quot;&quot;, false, &quot;&quot;, &quot;page2.aspx&quot;, false, false))" border="0" />

Has anyone experienced this or have any ways to resolve it?

Many thanks,

Rit
Avatar of jinn_hnnl
jinn_hnnl
Flag of Netherlands image

What's the problem with this one? Image doesn't show up because the name has been changed? I dont know why you have such out up after rendered.

Can you try to put ~ in the image source to tell compiler to navigate to your root folder?
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/button_logon.png" PostBackUrl="page2.aspx" />

You might wanna try to remove the PostBackUrl (put back later) and put in the OnClick to see if there is any change.

Hope this help

JINN
Avatar of rito1
rito1

ASKER

Hi,

The problem is that .Net is outputting the Image button HTML with the HTML attribute border="0" when the W3C validator is checking it, which is non W3C non-compliant.

Is there any way of stopping asp.net from adding this border attribute and just get it's style from my CSS file?

Thanks,

Rit
ASKER CERTIFIED SOLUTION
Avatar of jinn_hnnl
jinn_hnnl
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rito1

ASKER

thank you both