title: Javascript Alert in ASP.NET
body: <p>I want to use <a href="http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert" rel="nofollow">Javascript Alert</a> function in my ASP.NET page.</p>
  
  <p>For example like this;</p>
  
  <pre><code>Response.Write("&lt;script language=javascript&gt;alert('ERROR');&lt;/script&gt;);
  </code></pre>
  
  <p>But, this doesn't work.</p>
  
  <p>I ask in here what am i doing wrong and everyone suggest me using <a href="http://msdn.microsoft.com/en-us/library/bahh2fef.aspx" rel="nofollow">RegisterScriptBlock</a></p>
  
  <pre><code>ScriptManager.RegisterClientScriptBlock(this, this.GetType(), " ", "alert('ERROR')",true);
  </code></pre>
  
  <p>But i don't want use it because it's working with <code>PostBack</code></p>
  
  <p>How can i do that without <code>PostBack</code>?</p>
  
  <p>EDIT: For example for using;</p>
  
  <pre><code>try
  {
      string strConnectionString = ConfigurationManager.ConnectionStrings["SqlServerCstr"].ConnectionString;
  
      SqlConnection myConnection = new SqlConnection(strConnectionString);
      myConnection.Open();
  
      string hesap = Label1.Text;
      string musteriadi = DropDownList1.SelectedItem.Value;
      string avukat = DropDownList2.SelectedItem.Value;
  
      SqlCommand cmd = new SqlCommand("INSERT INTO AVUKAT VALUES (@MUSTERI, @AVUKAT, @HESAP)", myConnection);
  
      cmd.Parameters.AddWithValue("@HESAP", hesap);
      cmd.Parameters.AddWithValue("@MUSTERI", musteriadi);
      cmd.Parameters.AddWithValue("@AVUKAT", avukat);
      cmd.Connection = myConnection;
  
      SqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
      Response.Redirect(Request.Url.ToString());
      myConnection.Close();
  }
  catch (Exception)
  {
      Response.Write("&lt;h2&gt;ERROR&lt;/h2&gt;");
  }
  </code></pre>