Display exception message through javascript alert in asp.net
<p>I am trying to show exception message through javascript alert box.</p>

<p>Here is the sample code.</p>

<pre><code>public static void HandleException(Page page, Exception ex)
{
    string message = ex.Message.ToString();
    ScriptManager.RegisterClientScriptBlock(page, page.GetType(), "", "alert('"+message+"');", true);

}
</code></pre>

<p>It runs if i give literal values for the string variable. 
e.g.</p>

<pre><code>string message = "Hello World";
</code></pre>

<p>But it fails if I give message = ex.Message;</p>

<p>Any Idea?</p>
