Reputation: 3
I'm beginner in asp.net, I'm using below code for asp:Button
, it's working fine.
<asp:Button ID="btnLoadLoction" OnClientClick="this.value = 'Loading....';this.style.backgroundColor = '#DC143C';" runat="server" OnClick="btnLoadLoction_Click" Text="Load" />
Here problem with asp:linkbutton
, I'm trying to change button text to look like below:
<asp:LinkButton ID="btnLoadLoction" OnClientClick="this.value = 'Loading....'; this.style.backgroundColor = '#DC143C';" runat="server" CssClass="btn btn-info" OnClick="btnLoadLoction_Click"><span aria-hidden="true" class="glyphicon glyphicon-repeat"></span> Load</asp:LinkButton>
Upvotes: 0
Views: 1007
Reputation: 543
The problem is that LinkButton is rendered like the < a > html tag and when the client click is fired, you must work with javascript and rendered < a > html element... so the difference is that while a button has its text on value attribute, the < a > element don't, look how it's rendered, you'll see something like
<a id="btnLoadLoction" on-click="this.value = 'Loading....';this.style.backgroundColor = '#DC143C';" ><span aria-hidden="true" class="glyphicon glyphicon-repeat"></span> Load</a>
So, to change it's content (pay attention to "content" word... we're no more talking about an attribute value), you shall change his innerHTML property. Try to do something like
this.innerHTML ='Loading...' in your javascript
Upvotes: 3