title: JavaScript: Alert.Show(message) From ASP.NET Code-behind
body: <p>I am reading this <a href="http://archive.devnewz.com/devnewz-3-20061129JavaScriptAlertShowmessagefromASPNETCodebehind.html" rel="noreferrer">JavaScript: Alert.Show(message) From ASP.NET Code-behind</a></p>
  
  <p>I am trying to implement the same. So I created a static class like this:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Data;
  using System.Data.SqlClient;
  using System.Web;
  using System.Text;
  using System.Web.UI;
  
  namespace Registration.DataAccess
  {
      public static class Repository
      {
          /// &lt;summary&gt; 
          /// Shows a client-side JavaScript alert in the browser. 
          /// &lt;/summary&gt; 
          /// &lt;param name="message"&gt;The message to appear in the alert.&lt;/param&gt; 
          public static void Show(string message) 
              { 
                 // Cleans the message to allow single quotation marks 
                 string cleanMessage = message.Replace("'", "\'"); 
                 string script = "&lt;script type="text/javascript"&gt;alert('" + cleanMessage + "');&lt;/script&gt;"; 
  
                 // Gets the executing web page 
                 Page page = HttpContext.Current.CurrentHandler as Page; 
  
                 // Checks if the handler is a Page and that the script isn't allready on the Page 
                 if (page != null &amp;&amp; !page.ClientScript.IsClientScriptBlockRegistered("alert")) 
                 { 
                   page.ClientScript.RegisterClientScriptBlock(typeof(Alert), "alert", script); 
                 } 
              } 
      }
  }
  </code></pre>
  
  <p>On this line: </p>
  
  <pre><code>string script = "&lt;script type="text/javascript"&gt;alert('" + cleanMessage + "');&lt;/script&gt;"; 
  </code></pre>
  
  <p>It is showing me the error: <strong>; Expected</strong></p>
  
  <p>And also on </p>
  
  <pre><code>page.ClientScript.RegisterClientScriptBlock(typeof(Alert), "alert", script); 
  </code></pre>
  
  <p>Err: <strong>The type or namespace name 'Alert' could not be found (are you missing a using directive or an assembly reference?)</strong></p>
  
  <p>What am I doing wrong here? </p>