views:

63

answers:

3

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

+1  A: 

Are these the droids you are looking for?

It is a question phrased differently from what you have requested, but I have a feeling you both have the same end goal.

Serapth
that's an informative link.I guess my question is how to show "Loading" when the page is initially called.
Server_Mule
A: 

this helped http://stackoverflow.com/questions/31935/asp-net-ajax-firing-an-updatepanel-after-the-page-load-is-complete

look for the answer given by the person who asked the question

Server_Mule
This is the exact same link that Serapth provided
wweicker
you're right, same link, my mistake, sorry.
Server_Mule
+1  A: 

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
thanks Seanix, this looks good
Server_Mule