Agha Usman

Lives in Karachi (Pakistan) and work for Ciber Strategies

Disable Control When Asp.net AJAX is in progress

If the AJAX call to the server take too much time, then there is a possibility that user might press some other buttons or some other event occurred which will cause your AJAX call to stop and make a new request.

To overcome this situation, I decided to have div on the top of the page so that while AJAX call is in progress user cannot do any thing else.

So I simply Drag and Drop a Update Progress Control and write the following stuff.

<asp:UpdateProgress ID="UpdateProgress1" runat="server">
    <ProgressTemplate>
        <div id="Progress">Please wait ......</div>
       <div id="bgDiv"></div> 
    </ProgressTemplate>
</asp:UpdateProgress>

And add the following style on head section of the page.

   1: <style>
   2:     #bgDiv {
   3:       position:absolute;
   4:       top:0px;
   5:       bottom:0px;
   6:       left:0px;
   7:       right:0px;
   8:       overflow:hidden;
   9:       padding:0;
  10:       margin:0;
  11:       background-color:black; 
  12:       filter:alpha(opacity=50);
  13:       opacity:0.5;
  14:       z-index:500;
  15:     }
  16:     #Progress
  17:     {
  18:         position: absolute;
  19:         background-color:Red;
  20:         width: 300px;
  21:         z-index: 600;
  22:     }
  23:  
  24:  
  25:     </style>

There we go whenever AJAX call made, a background div will appear and on top of that we have our message “Please wait”

Here is the snapshot

image

Comments

Disable Control When Asp.net AJAX is in progress - Agha Usman said:

Pingback from  Disable Control When Asp.net AJAX is in progress - Agha Usman

# February 5, 2009 4:18 PM

tsantos said:

It's nice, but perhaps you'd like to check this CSS sample so you make it transparent for other browsers instead of just IE. Take a look here www.domedia.org/.../css-transparency.php

# February 5, 2009 4:28 PM

David Taylor said:

Hi,

Yes, I have been toying with the same issues.  I first disabled all the buttons and fields in client script - but this only worked in IE.

I now apply a CSS style to all buttons and fields to make them look disabled and simply return false; in my script methods (client side) if a partial update is happening.

I still like the user being able to keyboard and mouse over navigate while the update is happening because they can get ready for the next step while the update is happening.

Anyway....I am being pedantic as the updates only take 0.5 seconds in my app.

# February 5, 2009 7:58 PM

Webdiyer said:

You may try ModalUpdateProgress control: www.codeproject.com/.../ModalUpdateProgress.aspx

# February 5, 2009 10:33 PM

Cristovao Morgado said:

Just look at jQuery (here' an example disabling all <a>, but you can do the sabe for buttons...

Sys.Application.add_init(App_Init);

function App_Init() {

   Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);

   Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);

}

function BeginRequest(sender, args) {

   $("a").attr("disabled", "disabled");

}

function EndRequest(sender, args) {

   $("a").attr("disabled", "");

}

# February 6, 2009 10:42 AM

G said:

Wicked blog - helped me out today!

# May 9, 2009 1:10 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)