0

As it is not possible to use the font awesome in the Asp:Button. I came across to use the Font Awesome cheat sheet from the comment in this post as follows:

<asp:Button ID="btEdit" runat="server" CssClass="btn fa" Text="&#xf044;">
</asp:Button>

But now, Text="&#xf044;" looks so awkward. Is there some way to use constants, so use like this, Text="edit" and edit has the value &#xf044;

Community
  • 1
  • 1
Kamran
  • 4,010
  • 14
  • 60
  • 112

1 Answers1

0

One possible option:

Declare a constant variable to store the text -

protected const string AWESOME_EDIT = "&#xf044;";

Bind to it in the tag -

<asp:Button ID="btEdit" runat="server" CssClass="btn fa" Text='<%# AWESOME_EDIT %>'></asp:Button>

Unfortunately, then you have to explicitly databind the page (or particular item) -

private void Page_Load(object sender, EventArgs e)
{
    Page.DataBind();
    //or, btEdit.DataBind();
}
James
  • 411
  • 4
  • 20