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

后端 未结 4 732
名媛妹妹
名媛妹妹 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 09:02

    Simplifying RPM1984's very helpful earlier answer (thanks ;)) and showing some tweaks & a little more of the surrounding detail that I found necessary:

    
    
    
    
        
            
            
    
    

    Note:

    1. The hidden button's vital OnClick= parameter, this is what specifies the server function to call!

    2. No trigger clause or triggers in the Update-panel, I am using the child controls which are automatically triggers - specifically the button Click event.

    And to trigger it from client-side Javascript you can use:

    document.getElementById("hiddenAsyncTrigger").click‌​();
    

    However, I found it necessary to prevent this being called on subsequent page loads (as it caused unnecessary page load looping & consequent flicker). See the neat little IsPostBack() check below :)

    e.g. To invoke this after page load (as per the original question), I just added a call to invoke the above line of code as the onload-parameter to the main Body-tag thus:

    
    ...  
        
    
    

提交回复
热议问题