0

I wanted to create a search button on my form that uses a bootstrap glyphicon rather than the word "Search"

Unfortunately, ASPX only renders the Text of a button as a string so I can't add the glyphicon to the button with that (see below):

<asp:Button runat="server" id="btnSearch" Text="<i class='glyphicon glyphicon-search'></i>">
</asp:Button>

This renders the button with the whole tag written on the button as you see it in the code which is obviously not what I'm looking for.

How can I render this search button to show the glyphicon rather than a text string?

Ortund
  • 8,095
  • 18
  • 71
  • 139
  • 1
    Maybe this? https://stackoverflow.com/a/24288560/4707967 – Kevin Maxwell Jun 12 '17 at 11:12
  • Yup that does it, now I dunno if I should close the question or if that'll get me banned from asking again – Ortund Jun 12 '17 at 11:25
  • Possible duplicate of [How do I put a Bootstrap Glyphicon inside an asp:Button in ASP.Net?](https://stackoverflow.com/questions/24285570/how-do-i-put-a-bootstrap-glyphicon-inside-an-aspbutton-in-asp-net) – Kevin Maxwell Jun 12 '17 at 15:40
  • You won't be banned from asking again, but you need to search before adding a new question. StackOverflow is lot greater than an ocean, you can find any answer here. :) – Kevin Maxwell Jun 12 '17 at 15:45

1 Answers1

0

The alternative which I opted for was to add a search button with the icon as a LinkButton control:

<asp:TextBox runat="server" ID="txtSearch" placeholder="Search" />
<asp:LinkButton runat="server" ID="btnSearch">
    <span aria-hidden="true" class="glyphicon glyphicon-search"></span>
</asp:LinkButton>
Ortund
  • 8,095
  • 18
  • 71
  • 139