public override void AfterLoad() { var bc = new BusinessComponent(env, "Associates"); var idInput = (InputField)page.FindControl("ID"); bc.Edit(idInput.Value); var input = (InputField)page.FindControl("advSendEmail"); if (input != null && input.Value != null && input.Value.ToString() == "send") { try { var email = bc["email"]; if (email == null || string.IsNullOrEmpty(email.ToString())) { page.AddErrorMessage("Email is empty"); return; } var name = bc["TavoMama"]; SendEmail(email.Value.ToString(), name.ToString()); input.Value = null; } catch (Exception) { page.AddErrorMessage("Failed to send email"); } } }