Welcome Guest Search | Active Topics | Sign In | Register

AJAXUploader in an UpdatePanel works "too well" Options
UglyDuckling
Posted: Thursday, April 24, 2008 6:34:50 PM
Rank: Member
Groups: Member

Joined: 8/29/2007
Posts: 20
Here is the scenario,

I have a UserControl with a ModalPopupExtender, and in that extender panel is an UpdatePanel with an AJAXUploader on it. My UpdatePanel has an UpdateProgress control on it that displays a loading animated gif when the page is asynchronous postback.

Since AJAXUploader is asynchronous all on its own, when I upload a file, the ASP.NET AJAX PageRequestManager never initiates an async request until after the file is finished, so my loading animated gif doesn't display until the AJAXUploader is done and it posts back the file to the page.

This is expected behaviour, but how can I get the loading animated gif to appear while AJAXUploader is uploading, and then when the page is doing a partial page refresh via ASP.NET AJAX?
eo_support
Posted: Thursday, April 24, 2008 6:42:37 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,090
You can handle ClientSideOnProgress event to show/hide your animated gif.
UglyDuckling
Posted: Thursday, April 24, 2008 8:10:27 PM
Rank: Member
Groups: Member

Joined: 8/29/2007
Posts: 20
Works like a charm, thanks! For posterity, I did away with the UpdateProgress and used a simple div with display:none; then I rigged it up to both the PageRequestManager and the ClientSideOnProgress, so it sticks around for AJAXUpload as well as the postback at the end.

Quote:

<script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);

function InitializeRequest(s, e)
{
var div = $get('<%= divLoading.ClientID %>');
div.style.display = '';
}

function EndRequest(s, e)
{
var div = $get('<%= divLoading.ClientID %>');
div.style.display = 'none';
}

function ClientSideOnProgress(u, t, r)
{
var div = $get('<%= divLoading.ClientID %>');
div.style.display = t != r ? '' : 'none';
}
</script>


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.