Click here to Skip to main content
12,892,796 members (48,659 online)
Rate this:
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
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?
Annnaa 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
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:

   background: url('/img/disk.png');

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

<input type=button id="btnSave" class="saveBtn" value="Save"/>
Annnaa 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.
Rate this: bad
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..

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 7 Dec 2012
Copyright © CodeProject, 1999-2017
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