How can I defer loading UpdatePanel content until after the page renders?

后端 未结 4 730
名媛妹妹
名媛妹妹 2020-12-11 08:05

Old hand at ASP.NET, new to the UpdatePanel. I have a reporting page which executes a fairly length SQL query... takes about 10 seconds right now. What I would like to do

4条回答
  •  误落风尘
    2020-12-11 08:56

    Updating this with my solution, I pieced together mostly from the first answer above.

    I need my page to load, then then start loading content for my update panel. The panel calls some webservices and we don't want the whole page to crash in the event that the remote server doesn't respond. We don't want the wait either.

    My HTML:

    
            
                
                

    My Code behind snippets:
    In page_load:

    ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType, "LoadUpdate", GetPostBackEventReference(hiddenAsyncTrigger, String.Empty), True)
    

    And the button handler:

    Sub LoadUpdatePanels(ByVal o As Object, ByVal e As EventArgs) Handles hiddenAsyncTrigger.Click
            System.Threading.Thread.Sleep(5000)  'wait 5 seconds so I can see the page change
            imgSpinner.Visible = False
            lblWait.Text = "Content is now loaded."
            'udpCheckout.Update()
        End Sub
    

    This was my test to see if I could get it working. Now to replace all of this with the real code!

提交回复
热议问题