protected void ButtonAddFlat_Click(object sender, EventArgs e) { Page.Validate(); if (Page.IsValid) { try { string landlordEmail = Session["Email"].ToString().Trim(); string type = DropdownType.SelectedValue.ToString(); string address = TextBoxAddress.Text; string postCode = TextBoxPostCode.Text; string city = TextBoxCity.Text; string availableFrom = Calendar1.SelectedDate.ToString("dd/MM/yyyy"); double rent = Convert.ToDouble(TextBoxRent.Text.Trim()); double deposit = Convert.ToDouble(TextBoxDeposit.Text.Trim()); string description = TextBoxDescription.Text; String output = client.AddFlat(landlordEmail, type, address, postCode, city, rent, deposit, availableFrom, description); if (output.Trim().Equals("Successfully added.")) { LabelAddFlat.Text = "Successfully added."; Calendar1.SelectedDates.Clear(); } else if (output.Equals("Unable to add flat due to nonexisting landlord email.")) { LabelAddFlat.Text = "Unable to add flat due to nonexisting landlord email."; } else { LabelAddFlat.Text = "Unable to connect to database."; } } catch { Response.Redirect("ErrorPage.aspx"); } } }