简体   繁体   中英

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"/>

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>

因此,在asp.net中,至少到目前为止,简单的解决方案是

<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...';"/>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM