How do I put a Bootstrap Glyphicon inside an asp:Button in ASP.Net? How do I put a Bootstrap Glyphicon inside an asp:Button in ASP.Net? asp.net asp.net

How do I put a Bootstrap Glyphicon inside an asp:Button in ASP.Net?


You have to use asp:LinkButton instead of a asp:Button, here is how it works for me using Bootstrap 3 in an ASP.NET web-application:

From your code you can make the following work:

<asp:LinkButton ID="btnRandom"             runat="server"             CssClass="btn btn-primary"                OnClick="btnRandom_Click">    <span aria-hidden="true" class="glyphicon glyphicon-refresh"></span></asp:LinkButton>

Here is an example of what I use for a Submit Button with text "Submit":

<asp:LinkButton ID="SubmitBtn"                 runat="server"                 CssClass="btn btn-primary"                    OnClick="SubmitBtn_Click">    <span aria-hidden="true" class="glyphicon glyphicon-ok"></span>Submit</asp:LinkButton>


What is real use of ASP Server control when you can do that in HTML server control :

You can convert the HTML element to a server control by setting the runat="server" attribute.

<button runat="server" ><span aria-hidden="true" class="glyphicon glyphicon-refresh"></span>Refresh</button>


try this

<button id="btnSubSearch" runat="server" type="submit" class="btn btn-default" onserverclick="btnSubSearch_Click"><span aria-hidden="true" class="glyphicon glyphicon-search"></span></button>