protected void saveButton_Click(object sender, EventArgs e) { if (validate()) { if (hidCode.Value.Length == 0) { errorControl.AddErrorText("Please select a location before saving"); errorControl.Visible = true; return; } Location location = new Location(); location.LocationName = hidCode.Value; location.Latitude = (latitudeTextBox.Text.Trim() == String.Empty) ? null : latitudeTextBox.Text.Trim(); location.Longitude = (longitudeTextBox.Text.Trim() == String.Empty) ? null : longitudeTextBox.Text.Trim(); if (location.Latitude != null || longitudeTextBox != null) { location.NextAttemptDate = null; } else { location.NextAttemptDate = (nextAttemptLiteral.Text == String.Empty ? location.NextAttemptDate : Convert.ToDateTime(nextAttemptLiteral.Text)); } location.IncludeInUI = includeInUICheckbox.Checked; location.LastModifiedDate = DateTime.Now; location.IsNew = false; BHLProvider bp = new BHLProvider(); bp.SaveLocation(location); } else { return; } Response.Redirect("/Admin/LocationEdit.aspx"); }