0

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"/>
Community
  • 1
  • 1
Dr. Mian
  • 3,334
  • 10
  • 45
  • 69

3 Answers3

3

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>
Sachin
  • 40,216
  • 7
  • 90
  • 102
  • I got the following error Parser Error Message: The base class includes the field 'LoginButton', but its type (System.Web.UI.WebControls.Button) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlButton). – Dr. Mian Jul 07 '15 at 13:14
  • try cleaning the solution and rebuild it. Make sure there should not be two controls with same id `LoginButton` – Sachin Jul 07 '15 at 13:38
1

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...';"/>
Dr. Mian
  • 3,334
  • 10
  • 45
  • 69
0

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...

Mayank Patel
  • 1,563
  • 1
  • 14
  • 19
  • Thanks, that helped but ideally I am looking for this effect http://jsfiddle.net/AndrewDryga/zcX4h/1/ At the moment I am using asp.net with bootstrap plugin. Any suggestion? – Dr. Mian Jul 07 '15 at 13:57
  • 1
    I added the css part to the end of Bootstrap.css, javascript part in the head of the page under tag but it is not working – Dr. Mian Jul 07 '15 at 14:00