protected void Submit_Click(object sender, EventArgs e) { if (Page.IsValid) { string Firstname = FirstName.Text; string Lastname = LastName.Text; string Streetaddress1 = StreetAddress1.Text; string Streetaddress2 = StreetAddress2.Text; string city = City.Text; string Emailaddress = EmailAddress.Text; string Postalcode = PostalCode.Text; string Checkanswer = CheckAnswer.Text; string province = Province.SelectedValue; bool terms = Terms.Checked; if (terms) { Entry theEntry = new Entry(Firstname, Lastname, Streetaddress1, Streetaddress2, city, Emailaddress, province, Postalcode); contestentries.Add(theEntry); ContestEntries.DataSource = contestentries; ContestEntries.DataBind(); } else { Message.Text = "You did not agree to the terms of the contest. Entry Denied"; } } }
protected void Submit_Click(object sender, EventArgs e) { //on the server side you can rerun the validation //controls if (Page.IsValid) { string firstname = FirstName.Text; string lastname = LastName.Text; string streetaddress1 = StreetAddress1.Text; string streetaddress2 = StreetAddress2.Text; string city = City.Text; string email = EmailAddress.Text; string pc = PostalCode.Text; string province = Province.SelectedValue; bool terms = Terms.Checked; string answer = CheckAnswer.Text; //there maybe validation that cannot be done //using the basic validation controls //or //there may be a need for logic control //validation //was the checkbox checked? if (terms) { //create an instance of the Entry using the //greedy constructor Entry theEntry = new Entry(firstname, lastname, streetaddress1, streetaddress2, city, province, pc, email); //add to the collection of entries contestentries.Add(theEntry); //attach the collection of entries to the // GridView control ContestEntries.DataSource = contestentries; ContestEntries.DataBind(); } else { Message.Text = "You did not agree to the terms of the contest. Entry denied."; } } }
protected void Submit_Click(object sender, EventArgs e) { //On the server side, you can re-run the validation controls if (Page.IsValid) { string firstname = FirstName.Text; string lastname = LastName.Text; string streetaddress1 = StreetAddress1.Text; string streetaddress2 = StreetAddress2.Text; string city = City.Text; string province = Province.SelectedValue; string postalcode = PostalCode.Text; string email = EmailAddress.Text; bool terms = Terms.Checked; string answer = CheckAnswer.Text; //There may be validation that cannot be done using the basic validation controls OR there maybe a need for logic control validation if (terms) //Test to show if the checkbox was "checked" { //Message.Text = firstname + " " + lastname; //Create an instance of the Entry using the greedy constructor Entry theEntry = new Entry(firstname, lastname, streetaddress1, streetaddress2, city, province, postalcode, email); //Add to the collection of entries contestentries.Add(theEntry); //Atatch the collection of entries to the gridview control ContestEntries.DataSource = contestentries; ContestEntries.DataBind(); } else { Message.Text = "You did not agree to the terms of the contest. Entry Denied!"; } } }
protected void Submit_Click(object sender, EventArgs e) { //on the server side, you can rerun the validation controls if (Page.IsValid) { string firstname = FirstName.Text; string lastname = LastName.Text; string streetaddress1 = StreetAddress1.Text; string streetaddress2 = StreetAddress2.Text; string city = City.Text; string email = EmailAddress.Text; string pc = PostalCode.Text; string province = Province.SelectedValue; bool terms = Terms.Checked; string answer = CheckAnswer.Text; //there may be validation that cannot be done using the basic validation controls //or //there may be a need for logic control validation if (terms) //was the checkbox checked? { //Message.Text = firstname + " " + lastname; //Create an instance of the Entry using the greedy constructor Entry theEntry = new Entry(firstname, lastname, streetaddress1, streetaddress2, province, city, pc, email); //add to the collection of entries contestentries.Add(theEntry); //attach the collection of entries to the GridView control ContestEntries.DataSource = contestentries; ContestEntries.DataBind(); } else { Message.Text = "You did not agree to the terms of the contest. Entry denied."; } } //if(Terms.Checked == false) //{ // Message.Text = "You need to agree to Terms and Conditions!"; //} //else //{ // if(string.IsNullOrEmpty(CheckAnswer.Text)) // { // Message.Text = "You need to provide the calculation answer!"; // } // else // { // if(CheckAnswer.Text == "45") // { // Message.Text = "You have entered the following data: " + FirstName.Text + LastName.Text + ", " // + StreetAddress1.Text + StreetAddress2.Text + ", " + City.Text + ", " + Province.SelectedValue.ToString() // + ", " + PostalCode.Text + ", " + EmailAddress.Text; // } // else // { // Message.Text = "Sorry, but the answer " + CheckAnswer.Text + " is not correct! Please, try again!"; // } // } //} }