• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2590
  • Last Modified:

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!
0
YoungBonzi
Asked:
YoungBonzi
  • 4
  • 2
1 Solution
 
Jens FiedererCommented:
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.
0
 
YoungBonziAuthor Commented:
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.
0
 
YoungBonziAuthor Commented:
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?
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!

 
amit_gCommented:
specify the BorderWidth ...

<asp:Image ID="Image1" runat="server" CssClass="aspImageClass" BorderWidth="3px" />
0
 
YoungBonziAuthor Commented:
Ha! I didn't even see that property. Thank you =)
0
 
YoungBonziAuthor Commented:
Once I did that, the other instructions in the css class post will work.
0
 
amit_gCommented:
The CSS was working earlier too but the tag style would override the style given in class. So the width was being overridden.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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