title: How to get a server-side ASP page to display a pop-up message in the client's browser?
body: <p>Ok. I have read dozens of articles on the fact that you can't use MessageBox.Show from a server-side ASP page. Makes sense. Those articles were advocating using "alert" to pop up a message (like a confirmation message, where the user has to click "OK" to acknowledge the message). Some postings talked about registering the code, but others didn't. I have tried all of the combinations I could find, but I still can't get my server-side ASP page to pop up a message in my client's browser!</p>
  
  <p>Here's a snippet of the code in my code-behind page:</p>
  
  <pre><code>private void MessageBoxShow(Page page, string message)
  {
      Literal ltr = new Literal();
      ltr.Text = @"&lt;script type='text/javascript'&gt; alert('" + message + "') &lt;/script&gt;";
      page.Controls.Add(ltr);
  }
  </code></pre>
  
  <p>I have also tried this variation:</p>
  
  <pre><code>protected void MyTrace(string msg)
  {
      Response.Write("&lt;script&gt;alert('" + msg + "')&lt;/script&gt;");
  }
  </code></pre>
  
  <p>Both of these work as expected if I'm going to localhost, but when I put my code on the server (under IIS 7.5) the messages never appear.</p>
  
  <p>Can someone please give me a simple (but complete) answer that works? Thanks.</p>