[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

w3c validation on the <asp:imagebutton> control

Hello Experts

I am trying to validate one of my .net page with W3c validator. I am almost there however
one small issue which is causing a problem and I am unable to figure out how I can set the
Image type button not to show "border=0" in an inline-style element.

I am using the below server side control and on using its onlick click event on the server
side and redirecting the user to the results page...

<asp:ImageButton ID="btnSearch" runat="server" CausesValidation="False" ImageUrl="images/go.gif" ToolTip="Search"/>

The markup for the above button is visible as on the client side

<input type="image" name="ctl00$btnSearch" id="ctl00_btnSearch" title="Search" src="images/go.gif" border="0" />

It may be adding  border="0" because of this property in the CSS

style.css
---------
img
{
&#9;border:0px;
}


May be the validator things that an Input type button must not have a border attribute.


I hope someone understands what I am trying to explain here?

I would really be thankful if someone of you could please advise how I get away with
this problem? I have to use a Go button image in the background and it should be clickable to use server side onclick event.

Any help is appreciated.

Thanks
0
daira
Asked:
daira
1 Solution
 
LZ1Commented:
The W3C is saying exactly that. There is no attribute border for the <img> tag.  I'm not sure how you could do it in ASP, however, you may be able to remove it with some jquery after the DOM loads it.
$("#ctl00_btnSearch").removeAttr("border");

Open in new window

0
 
dairaAuthor Commented:
Hi LZ1
Thanks for your input
I have added the script into my js file but its doing it right. Please can you check for me?

http://validator.w3.org/check?uri=http%3A%2F%2Fstage.giftrepublic.com%2F&charset=%28detect+automatically%29&doctype=Inline&ss=1&group=0&user-agent=W3C_Validator%2F1.2

sonawanekiran:
Thanks for the link too but I did not understand how he managed to fix it?



0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LZ1Commented:
The JS is working, your right. However it's not validating because it's not processing the JS.  The good news is, if you take the source code and validate via direct input it validates perfectly!
0
 
LZ1Commented:
Couldn't you use a regular input rather than the asp input?
<input type="image" src="images/go.gif" ID="btnSearch" runat="server" CausesValidation="False" ToolTip="Search" title="Search"/>

Open in new window

0
 
dairaAuthor Commented:
Hi,
>>The good news is, if you take the source code and validate via direct input it validates perfectly!

Sorry I did not get this? Please advise
0
 
LZ1Commented:
If you right click on your page and then view source. Then copy and paste that into the validation direct input method, it validates perfectly.  

Have you tried my other suggestion?
0
 
dairaAuthor Commented:
Ok I understand. Thanks.

I have tested with the HTML and its passing the validation. However its failing for the asp.net page.

I am using server side user control for the button also because i have an onclick event which i am using to send the user to the result page ... I dont think its ideal to use client script for this?

I wonder if any .net expert can advise on this?

LZ1: please let me know if you have anything else for me to try?

Thanks
0
 
sybeCommented:
I would not worry about it. I don't think that html generated by asp.net is meant to pass the w3c validator. The html generated by asp.net webforms is absurdly ugly and unreadable. It is not meant to look at.

As long as it works, don't validate with w3c.

If you want valid, nice and clean html, then don't use webforms.
0
 
dairaAuthor Commented:
Hi Sybe

thanks for your advise

I have been asked to add the W3c validator logo on the homepage so I must get rid of this error somehow.

Please can you advise how I can use the simple button and use the "server_side_onclick" event to redirect the the user to the results page ...

At the moment I am using <imageButton> server contorl and using its onlick event server side I am redirecting the user as the results page does need to know the search keyword customer has supplied .... I hope you see what i mean?

Thanks
0
 
dairaAuthor Commented:
Hi,
Thanks for the link
I can see they are using <ASP:Button> control which I dont think I can use it? As I want to use server side onclick event which its not available for the Button control.
Thanks
0
 
LZ1Commented:
Again, I'm sorry for my lack of .NET knowledge. However, I'm not sure there is a solution if you absolutely need to validate directly prior to client rendering. There may be a workaround though:

http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/ac098c63-61ff-4b53-b5ad-72cb2eb0f7f2/
0
 
dairaAuthor Commented:
Thank you so much Liz1

Finally !

This document was successfully checked as XHTML 1.0 Transitional!

I have used the third option

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

Your help is greatly appreciated

Thank you ever so much!
0
 
LZ1Commented:
So glad you got it!  
0
 
dairaAuthor Commented:
thank you again for the help!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now