private void RegisterButton_Click(object sender, EventArgs e) { string name = NameTextBox.Text; string ageText = AgeTextBox.Text; int age = Int32.Parse(ageText); string challenge1 = ""; string challenge2 = ""; if (FirstChallengeComboBox.SelectedItem != null && FirstChallengeComboBox.SelectedIndex != -1) { challenge1 = FirstChallengeComboBox.SelectedItem.ToString(); } if (SecondChallengeComboBox.SelectedItem != null && SecondChallengeComboBox.SelectedIndex != -1) { challenge2 = SecondChallengeComboBox.SelectedItem.ToString(); } try { Child child = ctrl.RegisterChild(name, age, challenge1, challenge2); if (child != null) { ErrorLabel.Text = "A aparut o eroare ! "; } else { ErrorLabel.Text = ""; } } catch (ValidationException exception) { ErrorLabel.Text = exception.getErrors(); } }