Language: C#
C sharp
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { Response.Write(DropDownList1.SelectedValue); } protected void ButtonSave_Click(object sender, EventArgs e) { int n = SqlDataSource1.Insert(); if (n == 1) Response.Redirect("ViewGuestBook.aspx"); using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; // you need to add this line public partial class _Default : System.Web.UI.Page { protected void buttonSave_Click(object sender, EventArgs e) { string connectionString = "Data Source=COMP-WEB2;Initial Catalog=Guestbook;User ID=foo;Password=foobar"; SqlConnection connection = new SqlConnection(connectionString); SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = "INSERT INTO GuestBookEntries (VisitorName, VisitorEmail, Comments) VALUES (@VisitorName, @VisitorEmail, @Comments) "; command.Parameters.AddWithValue("@VisitorName", this.textBoxName.Text); command.Parameters.AddWithValue("@VisitorEmail", this.textBoxEmail.Text); command.Parameters.AddWithValue("@Comments", textBoxComments.Text); try { command.Connection.Open(); int rowschanged = command.ExecuteNonQuery(); if (rowschanged == 1) { textBoxComments.Text = ""; textBoxEmail.Text = ""; textBoxName.Text = ""; Response.Write("Done"); } } catch (Exception ex) { Response.Write(ex.Message); } finally { command.Connection.Close(); } } } private void ButtonCheck_Click(object sender, EventArgs e) { com.cdyne.ws.EmailVerNoTestEmail verifier = new com.cdyne.ws.EmailVerNoTestEmail(); com.cdyne.ws.ReturnIndicator indicator = verifier.VerifyEmail(TextBoxEmail.Text,"0"); MessageBox.Show(indicator.ResponseText); } } if (rowschanged == 1) { //textBoxComments.Text = ""; //textBoxEmail.Text = ""; //textBoxName.Text = ""; //Response.Write("Done"); Response.Redirect("ViewGuestBook.aspx");
Tags:
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

