title: How to trigger UpdateProgress on initial pageload in asp.net
body: <p><strong>Question:</strong>
  Why does my UpdateProgress not show during the initial page load but does for subsequent postbacks via button click?</p>
  
  <p>The only way I have managed to get this working is with a timer, which I'm not keen on. Is there another way?</p>
  
  <p>Can someone explain why <code>doSearch()</code> causes the updateprogress to work from a button click but not on pageload via docoment ready?</p>
  
  <p><strong>Code:</strong></p>
  
  <p>Js handler:</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(doSearch);
  
      function doSearch() {
          $('#&lt;%= UpdatePanel1Trigger.ClientID %&gt;').click();
          return false;
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>aspx:</p>
  
  <pre><code>//if i click this button the updateprogress works
  //and the panel loads
  &lt;asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="form-control"  
   OnClientClick="return doSearch();"  /&gt;
  
  &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"
      OnLoad="UpdatePanel1_Load" ChildrenAsTriggers="true"&gt;
      &lt;ContentTemplate&gt;
          &lt;asp:Button ID="UpdatePanel1Trigger" runat="server" 
                 style="display:none" OnClick="UpdatePanel1Trigger_Click" /&gt;
          &lt;%--gridview that takes a while to load--%&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  &lt;asp:UpdateProgress ID="UpdateProgress1" runat="server" 
      AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="1"&gt;
      &lt;ProgressTemplate&gt;
          &lt;asp:Image ID="imgUpdateProgress1" runat="server" 
          ImageUrl="~/Images/spinner.gif" AlternateText="Loading ..." ToolTip="Loading ..."/&gt;
      &lt;/ProgressTemplate&gt;
  &lt;/asp:UpdateProgress&gt;
  </code></pre>
  
  <p>Codebehind:</p>
  
  <pre><code>    protected void UpdatePanel1Trigger_Click(object sender, EventArgs e)
      {
          if (!String.IsNullOrEmpty(m_search))
          {
              performSearch(); //loads data for gridview in updatepanel
          }
      }
  </code></pre>