Click here to Skip to main content
11,639,554 members (65,146 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET C#4.0
How can i create a button that have a image and a text on it??
Posted 7-Dec-12 3:40am
Comments
joshrduncan2012 at 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?
Annnaa at 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'
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:

.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'

<input type=button id="btnSave" class="saveBtn" value="Save"/>
  Permalink  
v4
Comments
Annnaa at 7-Dec-12 10:35am
   
what assembly reference should i add?
BC @ CV at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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..
  Permalink  

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

  Print Answers RSS
0 Suvendu Shekhar Giri 330
1 Sergey Alexandrovich Kryukov 299
2 CPallini 187
3 himanshu agarwal 167
4 F-ES Sitecore 160
0 OriginalGriff 9,081
1 Sergey Alexandrovich Kryukov 8,812
2 Mika Wendelius 7,027
3 Suvendu Shekhar Giri 2,650
4 F-ES Sitecore 2,548


Advertise | Privacy | Mobile
Web04 | 2.8.150731.1 | Last Updated 7 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100