using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class blossomcounty : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string ConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]; string myStringVariable; using (SqlConnection cn = new SqlConnection(ConnectionString)) { try { cn.Open(); SqlCommand command = new SqlCommand(); command.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar)).Value = TextBoxName.Text.Trim(); command.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar)).Value = TextBoxEmail.Text.Trim(); command.Parameters.Add(new SqlParameter("@Mobile", SqlDbType.VarChar)).Value = TextBoxMobile.Text.Trim(); command.Parameters.Add(new SqlParameter("@Enquiry", SqlDbType.VarChar)).Value = TextBoxEnquiry.Text.Trim(); command.CommandText = "Insert Into logix_county(Name,Email,Mobile,Enquiry) " + "Values(@Name,@Email,@Mobile,@Enquiry)"; command.Connection = cn; command.ExecuteNonQuery(); cn.Close(); } catch (Exception ex) { Response.Write(ex.ToString()); return; } } myStringVariable = "Thank you for your details. One of our representative will get back to you shortly."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true); TextBoxEmail.Text = ""; TextBoxMobile.Text = ""; TextBoxName.Text = ""; TextBoxEnquiry.Text = ""; Response.Redirect("logixthankyou.html"); } }