user1416156
user1416156

Reputation: 3023

Change text on link while loading

I have a asp button that while processing i would like the text on it.. How could achieve that?

<asp:LinkButton ID="loadImages" runat="server" CssClass="button"
       onclick="loadImages_Click">Load Images</asp:LinkButton>

So when I click, it will change the Load Images to Loading... and then go back to the original state once it finishes.

I would appreciate any ideas.

Upvotes: 0

Views: 632

Answers (2)

canon
canon

Reputation: 41675

OnClientClick...

<asp:LinkButton OnClientClick="this.innerHTML = 'loading'" ...

Once the page posts back the text will revert to "Load Images"

Upvotes: 3

Alex
Alex

Reputation: 35407

To change the text of a link when a user clicks on it use the onclick JavaScript event:

window.addEventListener('load', function(){
    var link = document.getElementById('<%=loadImages.ClientID %>');

    link.addEventListener('click', function(){
        this.innerHTML = 'loading ...';
    }, false);
}, false);

This snippet will change the text of the link before the request to the server is made. Once the server responds the page will refresh with the newly rendered HTML from the response.

Upvotes: 1

Related Questions