Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my application i m using button. i want to apply background image to button i m writing below code but it does not display background image to button.i dont want to use image button control.
css file
CSS
.buttons
{

background-image:url('/img/button_2.png/') ;


}

source code
C#
<asp:Button ID="Button1" runat="server" CssClass="buttons" Text="edit" />
Posted
Updated 25-May-12 2:06am
v3
Comments
abhijeetgupta1988 25-May-12 8:13am    
background-image:url('/img/button_2.png/') ;


after image name you used "/"
preet88 25-May-12 8:28am    
hi manohar
Abhijeet has given right answer. The best way to avoid this kind of errors is use the features of framework Drag-Drop image which you want to display.

Why not use an ImageButton [^]control?
 
Share this answer
 
Comments
Prasad_Kulkarni 25-May-12 8:24am    
I thought the same.. +5!
Manas Bhardwaj 25-May-12 8:55am    
:)
Use its CssClass property say you have button like following

CSS
.myBtn
{
   background:transparent url('myImage.png') no-repeat;
}

now apply this class in your button in CssClass property.

Use Image Button[^] control instead of CSS.

In addition, please refer:
Simple way to Design Tabs in ASP.NET[^]
This article will show how to Create Tabs in ASP.NET page using Buttons, MultiView Control and CSS
 
Share this answer
 
v3
Comments
Manas Bhardwaj 25-May-12 8:56am    
+5 for expalanation!
Prasad_Kulkarni 25-May-12 9:11am    
Thank you Manas!
Try something like this in your CSS class

.buttons
{
 

 background: url(images/orange_button_bg.gif) no-repeat 25% 50% #FF8800;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900