I want to use Javascript Alert function in my ASP.NET page.
For example like this;
Response.Write("<script language=javascript>alert('ERROR');</script>);
But, this doesn't work.
I ask in here what am i doing wrong and everyone suggest me using RegisterScriptBlock
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), " ", "alert('ERROR')",true);
But i don't want use it because it's working with PostBack
How can i do that without PostBack?
EDIT: For example for using;
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("<h2>ERROR</h2>");
}