protected void ButtonRegister_Click(object sender, EventArgs e) { if (IsPostBack) { try { if (DropDownListType.SelectedValue == "Landlord") { ServiceReference1.MdlLandlord landlord = new ServiceReference1.MdlLandlord(); landlord.Address = TextBoxAddress.Text; landlord.City = TextBoxCity.Text; landlord.Contact_person = TextBoxSurnameAndContact.Text; landlord.Country = TextBoxCountry.Text; landlord.Email = TextBoxEmail.Text; landlord.Name = TextBoxName.Text; landlord.Password = TextBoxPassword.Text; landlord.Phone = TextBoxPhone.Text; landlord.PostCode = TextBoxPostCode.Text; if (client.AddLandlord(landlord).Trim().Equals("Registration successful.")) { LabelRegistration.Text = "Registration successful."; ClearFields(); } else if (client.AddLandlord(landlord).Trim().Equals("Registration has failed due to the existing Email.")) { LabelRegistration.Text = "Registration has failed due to the existing Email."; } else { LabelRegistration.Text = "Unable to connect to database."; } } else if (DropDownListType.SelectedValue == "Student") { ServiceReference1.WcfEFlatsServiceClient client = new ServiceReference1.WcfEFlatsServiceClient(); ServiceReference1.MdlStudent student = new ServiceReference1.MdlStudent(); student.Address = TextBoxAddress.Text; student.City = TextBoxCity.Text; student.Surname = TextBoxSurnameAndContact.Text; student.Country = TextBoxCountry.Text; student.Email = TextBoxEmail.Text; student.Name = TextBoxName.Text; student.Password = TextBoxPassword.Text; student.Phone = TextBoxPhone.Text; student.PostCode = TextBoxPostCode.Text; if (client.AddStudent(student).Trim().Equals("Registration successful.")) { LabelRegistration.Text = "Registration successful."; ClearFields(); } else if (client.AddStudent(student).Trim().Equals("Registration has failed due to the existing Email.")) { LabelRegistration.Text = "Registration has failed due to the existing Email."; } else { LabelRegistration.Text = "Unable to connect to the database"; } } } catch { Response.Redirect("ErrorPage.aspx"); } } }