views:

1474

answers:

4

What is the easiest way to hide the Contents of an Update Panel when the UpdateProgress is invoked?

+1  A: 

I'm not sure if this will work but you can put script tags inside the progresstemplate and hide a div inside the updatepanel. It most likely won't un-hide when it comes back though. You could catch the postback when it returns with javascript like so:

  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(){ 
        alert('postback returned'); 
   });
Paul U
A: 

Another way you can do it is make your content invisible at first like this:

<div id="content" style="display: none;">
</div>

Then end every update by adding this to the end of the content template:

<script type="text/javascript">
document.getElementById("content").style.display = "block";
</script>

I haven't tried this myself but I believe it should work.

EDIT -- I just realized this probably won't work quite like you want it to. The content will be invisible as its loading, and it'll become visible after it's done. But the content won't disappear until it receives that first byte from the server. That may or may not be the effect you're looking for depending on what kind of load times you're seeing.

Steve Wortham
+1  A: 

Here is a nice example doing this using Ajax Control Toolki

<ajaxToolkit:UpdatePanelAnimationExtender ID="ae"
  runat="server" TargetControlID="up">
     <Animations>
        <OnUpdating> ... </OnUpdating>
        <OnUpdated> ... </OnUpdated>
    </Animations>
</ajaxToolkit:UpdatePanelAnimationExtender>

*  TargetControlID - ID of the UpdatePanel  whose updates are used to play the animations (this is also the default target of the animations)
* OnUpdating - Generic animation played as when any UpdatePanel begins updating
* OnUpdated - Generic animation played after the UpdatePanel has finished updating (but only if the UpdatePanel was changed)

Also you may watch this video

Issa Qandil
This looks great, but a bit overkill. Isn't there a simple way to just hide the UpdatePanel during the UpdateProgress?
Farinha