title: Server Side Javascript Alert in C#
body: <p>I'm attempting to create an alert that works on the server side, preferably using JavaScript. This alert is displayed if a user's input does not match a value pulled from a SQL server. The client side alert I was using was:</p>
  
  <p><code>MessageBox.Show("User Input was not found. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);</code></p>
  
  <p>I attempted to replicate this by doing:</p>
  
  <pre><code>   string message = "User Input was not found. Please try again.";
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     sb.Append("&lt;script type = 'text/javascript' runat = 'server'&gt;");
     sb.Append("window.onload=function(){");
     sb.Append("alert('");
     sb.Append(message);
     sb.Append("')};");
     sb.Append("&lt;/script&gt;");
     Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
  </code></pre>
  
  <p>I also tried this:</p>
  
  <pre><code>   ClientScriptManager cs = Page.ClientScript;
     cs.RegisterClientScriptBlock(
     this.GetType(),
     " ",
     @"&lt;script language=javascript&gt;alert('User Input was not found. Please try again');&lt;/script&gt;",
     true
     );
  </code></pre>
  
  <p>After this alert is displayed, I'd like to immediately redirect using <code>Respone.Redirect("redirectpage.aspx")</code>. </p>
  
  <p>Is there a more effective solution to this issue? Am I missing something from my code? This is my first time using JavaScript for server side applications, so any detail would be appreciated.</p>