0

I am using an UpdatePaenl in an asp.net page. It has a button to trigger it. I'm able to show "Loading" when the button is pressed. Here's my issue: I need it to show "Loading" when the page is first called, not just when a button is pressed.

I would imagine that JavaScript would be used to trigger the UpdatePanel when the page is first loaded.

Any ideas are greatly appreciated. Thanks

Server_Mule
  • 579
  • 3
  • 9
  • 17

1 Answers1

1

You should be able to do this in javascript by setting up an event to fire after the page is loaded:

// Define the pg_Loaded() function as the handler for the PageLoaded event
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pg_Loaded);

var blnFirstPageVisit = true;

function pg_Loaded() 
{
    if (blnFirstPageVisit == true) 
    {
        // Display loading animation
        fnToggleLoading();

        // Trigger button postback event
        <asp:literal runat="server" id="ltlExecute" />

        // Prevent this from firing a second time after the postback completes
        blnFirstPageVisit = false;
    }
}

In ASP set the literal text like so:

ltlExecute.Text = ClientScript.GetPostBackEventReference(btnExecute, "")

More information exists at MSDN: http://msdn.microsoft.com/en-us/library/bb311028.aspx

wweicker
  • 4,833
  • 5
  • 35
  • 60