Font awesome inside asp button

This is my asp:button code which is not rendering font awesome’s icon but instead shows the HTML as it is:

  <asp:Button runat="server" ID="btnRun" Text="<i class='icon-camera-retro'></i> Search" ValidationGroup="edt" OnClick="btnRun_Click"  CssClass="greenButton"/>

Any idea how can I solve this issue?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You can’t with the default button you will need to use a HTML button and give it runat=server attribute:

<button runat="server" id="btnRun" class="btn btn-mini" title="Search">
    <i class="icon-camera-retro"></i> Search

So use code behind with this you add:

To the button, then in your C# do:
protected void functionName(object sender, EventArgs e)
    Response.Write("Hello World!!!");

So final button looks like:
<button runat="server" id="btnRun" onserverclick="functionName" class="btn btn-mini" title="Search">
    <i class="icon-camera-retro"></i> Search

Method 2

You can use a LinkButton

<asp:LinkButton runat="server" ID="btnRun" Text="<i class='icon-camera-retro'></i> Search" 
                ValidationGroup="edt" OnClick="btnRun_Click" CssClass="greenButton" />

They do support html in the text field.

Method 3

You can do it, jut not purely with CSS. You just need to set the Text property on the button to the unicode value of the fontawesome character and give the button the ‘fa’ css class so it takes up the fontawesome font.

<asp:Button ID="Button1" runat="server" 
    Text="xF135" CssClass="fa" />

I made this helper library that provides all the icon codes strongly-typed if that turns your crank:
<asp:Button ID="Button1" runat="server" 
    Text="<%# FontAwesome.Icons.Rocket %>" CssClass="fa" />

Nuget: Install-Package FontAwesome-ASP.NET


Method 4

Use LinkButton

<asp:LinkButton runat="server" ID="btnRun" ValidationGroup="edt" OnClick="btnRun_Click" CssClass="greenButton" > <i class='icon-camera-retro'></i> Search </asp:LinkButton>

Method 5

You can also try this solution –

<span  style="position:relative;">
    <i class="fa fa-hand-o-down"></i>
    <asp:Button ID="btnCatMoveDown" CssClass="movedown" CausesValidation="false" Text="" CommandName="categorymovedown" CommandArgument='<%#Eval("SomeId")%>' runat="server"></asp:Button>

    .movedown {

Method 6

In the others answers changes asp:button by other one, I show you if you want use asp:button, EASY 🙂

/*Colors depends what btn you use, in this case i´m using btn-default*/

    border: 0;
    background-color: #fff;

.btn:hover > .btn_asp_icon{
    background-color: #e6e6e6;
<!-- HTML -->

<div class="btn btn-default">

<i class="fa fa-search fa-fw fa-lg" aria-hidden="true"></i>
<asp:Button cssClass="btn_asp_icon" runat="server" text="Consultar"/>   


Method 7

Get it on Nuget!

Install-Package FontAwesome-ASP.NET

FontAwesome Icons In Webforms Buttons

You can use FontAwesome icons inside webforms button controls. Simply databind to the icon of your choice from the FontAwesome.Icons class’ static properties. Then either call DataBind() on your button or DataBind() on your parent control or page.

<asp:Button ID="Button1" runat="server" 
    Text="<%# FontAwesome.Icons.Rocket %>" CssClass="fa" />

Method 8

Put this in your Load form method:

btn_Test.Text = "Hello " + FontAwesome.Icons.LongArrowRight;

And the CssClass button:


Method 9

This code worked for me for v5.15

I had to add the following files to a folder named fonts under wwwroot

  1. FontAwesome.otf
  2. fontawesome-webfront.eot
  3. fontawesome-webfront.svg
  4. fontawesome-webfront.ttf
  5. fontawesome-webfront.woff
  6. fontawesome-webfront.woff2
    <a asp-controller="Controller" asp-action="CSHTMLFILE"><i class="fa fa-1x fa-arrow-left "></i> Go Back to Previous Page</a>  

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x