title: how to show exception variable value in alert box in asp.net using C#
body: <p>I have the following code, but the alert box is not displaying.</p>
  
  <pre><code>try
  {
      do something..          
  }
  catch(Exception ex)
  {
      Response.Write("&lt;script&gt;alert('"+ex+"')&lt;/script&gt;");
  }
  </code></pre>
  
  <p>If I use this code, the alert box appears.</p>
  
  <pre><code>try
  {
      do some thing
  }
  catch (Exception ex)
  {           
      Response.Write("&lt;script&gt;alert(\"an error occur\")&lt;/script&gt;");
  }
  </code></pre>
  
  <p>How can I display the exception variable in an alert box?</p>