Link to home
Start Free TrialLog in
Avatar of YoungBonzi
YoungBonziFlag for United States of America

asked on

Applying a CSS Class to an ASP:Image Tag

I'm having some trouble trying to figure this out.

something in my css like:

.aspImageClass { border:3px solid #666666; }

and in my aspx file:
<asp:Image ID="Image1" runat="server" CssClass="aspImageClass" />

Won't work.

It seems that <asp:Image> tags aren't affected by the css "img {}" instructions either.


Anyone know how to write a CSS class for an ASP:Image tag?

Thanks!
Avatar of Jens Fiederer
Jens Fiederer
Flag of United States of America image

The CSS functions on HTML tags, not ASP tags....by the time your browser sees the HTML to which to APPLY the CSS, the ASP tags are long gone.

Try doing a "View Source" in your browser to see what tags you should REALLY be affecting.
Avatar of YoungBonzi

ASKER

Ahh, I see. The source does render an HTML img tag, but for some reason the server is adding:
style="border-width:0px;"

Even when I override the img tag in the css file.
Hmm...you know what, someone else is having the same problem: http://www.webmasterworld.com/microsoft_asp_net/3363448.htm

I have my asp:image in a content placeholder too. Maybe this isn't a 50 point question. But if I have to just change the tag to a regular image tag then perhaps I should delete this?
ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America 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
Ha! I didn't even see that property. Thank you =)
Once I did that, the other instructions in the css class post will work.
The CSS was working earlier too but the tag style would override the style given in class. So the width was being overridden.