1

Is there anyway in ASP.NET application, when I click a button anywhere in the application, if the server response takes more than 2 seconds to change the cursor to Hourglass?

I really dont want to write code in each and every page.

ulluoink
  • 2,775
  • 2
  • 17
  • 22
Yass
  • 592
  • 1
  • 8
  • 30

1 Answers1

1

Edited:

Sorry, I think I misread your question. Here you go, this should change all buttons (input type submit and button) in a page to do the desired behavior.

<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        $("input:submit, input:button").click(function () {
            setTimeout(function () {
                document.body.style.cursor = 'wait';
            }, 2000);
        });
    });
</script>
Hanlet Escaño
  • 17,114
  • 8
  • 52
  • 75
  • I really hate when people downvote an answer and do not provide feedback or write an answer themselves. It's like SO is full of trolls lol. – Hanlet Escaño Dec 12 '12 at 06:36
  • Thank you, but it didn't help me. This script executes only when the DOM objects are ready, but my requirement is, I have to display the busy cursor when a response takes more than 2 secs. – Yass Dec 13 '12 at 02:53
  • @Yass if you want to change the style, property or attribute of any element you need to modify the element itself, which is contained within the DOM. This is a Web page, not a Desktop app. When you change the cursor, you are actually changing the style of the body, or of any other HTML element within your page, therefore, the same must be "ready" or "loaded". I am going to think about some other solution to try and help you :) – Hanlet Escaño Dec 13 '12 at 04:56