I am making an ASP.NET application (C #). [Visual Studio 2010]
In the case when I try to use a client-side message using javascript, it shows me a message when the update panel is not in use.
But as soon as I added the update panel to my application to prevent it from posting back, it will not show me such a javascript message when inserting a record.
In the following example, I am trying to display a message:
Response.Write("<head><script type='text/javascript'>alert('Member Registered Sucessfully')</script></head>");
My code is:
try { con.Open(); cmd = new SqlCommand("insert into register values(@name,@city,@address,@mobile)",con); cmd.Parameters.AddWithValue("@name",txtName.Text); cmd.Parameters.AddWithValue("@city", ddlCity.Text); cmd.Parameters.AddWithValue("@address",txtAddress.Text); cmd.Parameters.AddWithValue("@mobile", txtMobile.Text); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds); int res=cmd.ExecuteNonQuery(); if (res > 0) { Response.Write("<head><script type='text/javascript'>alert('Member Registered Sucessfully')</script></head>"); } else { Response.Write("<head><script type='text/javascript'>alert('Member Not Registered Sucessfully')</script></head>"); } con.Close(); }
Please tell me where I am doing the workshop.
I beg you, please.
source share