Farinha
Farinha

Reputation: 18091

Hide UpdatePanel during UpdateProgress

I'm looking for the easiest possible way to hide an UpdatePanel while waiting for the submit response to come back. Stuff like described here - using Ajax Control Toolkit and the UpdatePanelAnimationExtender is both overkill and causing some issues, namely:

A simple javascript solution would be ideal. The problem here is ASP.NET likes to generate weird IDs for the controls at runtime. Any solutions for that?

Thanks in advance.

Upvotes: 2

Views: 6069

Answers (3)

Evgeny Gorb
Evgeny Gorb

Reputation: 1531

Handle PageRequestManager beginRequest and endRequest events to control UpdatePanel's visibility during postbacks:

    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(
        function (sender, args) {
            $get("<%=someUpdatePanel.ClientID %>").style.display = "none";
        }
    );
    prm.add_endRequest(
        function (sender, args) {
            $get("<%=someUpdatePanel.ClientID %>").style.display = "";
        }
    );

Also add DisplayAfter="0" to assotiated UpdateProgress control to prevent delay between UpdatePanel hiding and UpdateProgress showing

Upvotes: 2

mracoker
mracoker

Reputation: 886

I would suggest using jQuery. It will make things easier for you. So to get around the "weird ID" issue you could do some jQuery like this:

$('#<%= someASPControl.ClientID %>').hide();

and to show:

$('#<%= someASPControl.ClientID %>').show();

This is using jQuery to grab a element by id and then you can do what you want with it. The trick is the ".ClientID" that will grab the id that .net sends out.

Upvotes: 0

CeejeeB
CeejeeB

Reputation: 3114

You can uses code tags in your html page and use the ClientId property of a control to spit out the id asp.net generates:

$('#<%= elementName.ClientID %>').hide();

EDIT: This example uses jQuery btw

Upvotes: 0

Related Questions