title: Code to check when page has finished loading
body: <p>How can I check whether the page has finished loading? When it has, how can I execute a method already created in the C# code behind for that page?</p>
  
  <p>I would like to orchestrate the following sequence of events</p>
  
  <ol>
  <li>Finish Loading the page</li>
  <li>Download a gridview as an Excel file in the page</li>
  <li>Call this method <code>download()</code></li>
  <li>Close the browser</li>
  </ol>
  
  <p>How can I accomplish this?</p>