title: Catching an exception if there's no connection
body: <p>I've got a website in asp.net / c# that updates an SQL server, which currently is working fair enough. However, I'm looking at taking it onto mobile devices and wondering what to do if the device loses connection. Basically, I'm wanting to catch it if it can't connect when the user tries to make edits.</p>
  
  <p>The basic code is:</p>
  
  <pre><code>try
  {
      Conn.Open();
  }
  catch (SqlException)
  {
      Session["HaveWeUpdated"] = 0;
      Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "alertMessage", "alert('Error')", true);
  }
  finally
  {
      Conn.Close();
  }
  </code></pre>
  
  <p>Which should bring up the pop-up message if it can't connect, as well as set our HaveWeUpdated session value to 0. Unfortunately, at the moment, when I try it (simply by pulling the cable out of my PC) it goes to the standard IE8 "diagnose connection problems" page and does NOT show the pop-up message - hence, I guess, it's not being caught.</p>