Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i create a button that have a image and a text on it??
Posted
Comments
joshrduncan2012 7-Dec-12 10:03am    
You have to give us more information. What IDE are you using? What is your intended use for this button creation?
lovitaxxxx 7-Dec-12 10:06am    
i am using vs 2010 and i am working on a web app
i want to create for example a 'save' button..
& i want it to have a image and the text 'SAVE'

Add This CSS to your HTML in a STYLE tag or better yet put it in a .css file and reference it in a Link tag:

CSS
.saveBtn
 {
   background: url('/img/disk.png');
   background-position:center;
   background-repeat:no-repeat;
}



Here is the HTML input object. The CSS references it by the class name 'saveBtn'

HTML
<input type=button id="btnSave" class="saveBtn" value="Save"/>
 
Share this answer
 
v4
Comments
lovitaxxxx 7-Dec-12 10:35am    
what assembly reference should i add?
BC @ CV 7-Dec-12 11:12am    
Assembly reference is irrelevant. The above CSS will add the picture to the background of any Input element, which is the HTML element output by the ASP Button object. You could and probably should use a class name to reference it instead though. I will update the solution so its more clear what you should do.
Button btn = new Button();
btn.Image = new Bitmap("btn.png");  // image
btn.Location = new System.Drawing.Point(120, 10);
btn.Name = "MyCustomBtn";
btn.Text = "I'm a Custom Button.";  // text
tabControl1.Controls.add(btn);  // add custom to tab control..
 
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