I am looking for a solution where I will be able to add an image and text both in asp.net button.
<asp:Button ID="Button1" runat="server" Text="Button"/>
I am only able to specify text to the button, but how can I add an image as well to it?
I am looking for a solution where I will be able to add an image and text both in asp.net button.
<asp:Button ID="Button1" runat="server" Text="Button"/>
I am only able to specify text to the button, but how can I add an image as well to it?
You can also use a font icon instead of an image.
CSS
You can remove the
background
andfilter
part in the classbutton
in the above style. I just used it for the gradient background for the button.HTML
Button looks like below.
Fiddle demo here
And even you can change the icon color by just adding color to the
<i>...</i>
. Something like below.By default, ASP .Net doesn't have a button which can render both image and text at the same time. However, you can achieve in two ways.
Using CSS
I prefer CSS because it is light weight, and you can style it whatever you want.
Third Party Control
It works right out of the box. However, you cannot change their style easily.
Use third party control like Telerik RadButton.
Last but not least if you want, you can implement a custom server control by yourself.