Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

adding an image to an image button using css

Posted on 2008-10-02
12
Medium Priority
?
377 Views
Last Modified: 2012-05-05
I have the following css class:
.POWMoreInfo
{
   background: url("../images/btn_info_org.png") top left no-repeat;
}

I then have the image button:
<asp:ImageButton ID="btnMoreInfo" runat="server" PostBackUrl="../Advertising.aspx" AlternateText="More Information" />            

in my code behind i set the css class of the button to use the class i have shown here.

This works but i also get an error image because i have not set imageurl for the button.

Is there a way around this?

I have attached a screenshot just to show what i mean.
example.jpg
0
Comment
Question by:scm0sml
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
  • 2
12 Comments
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 22627042
Try..

.POWMoreInfo
{
   background: url("<%=ResolveUrl("~")%>images/btn_info_org.png") top left no-repeat;
}
0
 

Author Comment

by:scm0sml
ID: 22627058
its not a problem with the css. the image is showing from the css.

its the image button thats moaning
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 22627068
I dont see a "src/source" attribute for your image button.
0
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.

 

Author Comment

by:scm0sml
ID: 22627370
the question says it happens in the code behind.

this is the code to do it:
btnMoreInfo.CssClass = "POWMoreInfo"
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 22627872
Don't think you can do it with ImageButton. Try LinkButton instead.
If you do decide to use LinkButton, make sure you add display:block in your CSS.
0
 

Author Comment

by:scm0sml
ID: 22628082
couldnt get it working.

cant believe how much time ive spent trying to do something so simple :(
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 22628121
You mean LInkButton does not work for you?
0
 

Author Comment

by:scm0sml
ID: 22628131
nope
0
 
LVL 22

Accepted Solution

by:
prairiedog earned 2000 total points
ID: 22628169
How about adding width and height in your CSS?
width:32px;
height:32px;
Change the numbers to match your actual image size. Remember, you will also need to add display:block; in your css.

.POWMoreInfo
{
	background:url("("../images/btn_info_org.png") top left no-repeat;
	display:block; 
	width:32px;
	height:32px;
}

Open in new window

0
 

Author Comment

by:scm0sml
ID: 22628241
yeah ok that is now showing the image.

while u r on a roll can u see what is wrong with this?

.POWMoreInfo
{  
 background:url("../images/btn_info_org.png") top left no-repeat;
      display:block;
      width:98px;
      height:25px;

}

.POWMoreInfo a:hover
{  
    background:url("../images/btn_info_org2.png") top left no-repeat;
      display:block;
      width:98px;
      height:25px;
}

i have just changed the image name wanting it to show a different image when u hover over the button
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 22628411
Change .POWMoreInfo a:hover
To:
 .POWMoreInfo:hover
0
 

Author Closing Comment

by:scm0sml
ID: 31502488
top man!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question