drmaa
drmaa

Reputation: 3684

How to add span tag to button in asp.net c#

I am trying to add spinner to the button. I searched and I found the simplest way is describe by Flion on this link. I dont know how add the suggested button code to my asp.net button.

Suggested code is

<button class="btn btn-lg btn-warning">
<span class="glyphicon glyphicon-refresh spinning"></span> Loading..</button>

and my code is

<asp:Button ID="LoginButton" runat="server" OnClick="Button1_Click" Text="Login" CssClass="btn btn-primary col-xs-12"/>

Upvotes: 0

Views: 4992

Answers (3)

drmaa
drmaa

Reputation: 3684

So in asp.net, the simple solution at least for now is

<asp:Button ID="LoginButton" runat="server" OnClick="Button1_Click" Text="Login" CssClass="btn btn-primary col-xs-12" UseSubmitBehavior="false" OnClientClick="this.value='Please wait...';"/>

Upvotes: 1

Mayank Patel
Mayank Patel

Reputation: 1571

this may help you

<button id="btn" runat="server" onserverclick="Button1-Click"> <span>Click</span></button>

try using this code if it helps...

Tell me if it helps...

Upvotes: 0

Sachin
Sachin

Reputation: 40970

You can use the suggested code as it is. You just need to use the runat="server" to access that html button at code behind. Apart from this you also need to setup the onclick event like this

<button class="btn btn-lg btn-warning" runat="server" onclick="Button1_Click" id="LoginButton">
    <span class="glyphicon glyphicon-refresh spinning"></span>Loading..
</button>

Upvotes: 3

Related Questions