protected override void Render(HtmlTextWriter writer) { Label result = new Label(); if (!(string.IsNullOrEmpty(EmailAddress))) { string[] splittedEmailAddress = EmailAddress.Split(new char[] { '@' }); // Let's do a very basic check of the email address: // - it must not start with "@" // - it must not end with "@" // - it must contain the character "@" exactly 1 time, so the splitted array must have 2 elements if ((EmailAddress.StartsWith("@")) || (EmailAddress.EndsWith("@")) || (splittedEmailAddress.Length != 2)) { throw new HttpException(string.Format("The email address of '{0}' is not valid: \"{1}\"", ID, EmailAddress)); } if (!(string.IsNullOrEmpty(CssClass))) { result.Text = string.Format("<a href=\"{0}:{1}('{2}','{3}','{4}');\" class=\"{5}\">{6}</a>", "javascript", "ftbs", splittedEmailAddress[0], splittedEmailAddress[1], Subject, CssClass, (string.IsNullOrEmpty(DisplayValue) ? EmailAddress : DisplayValue)); } else { result.Text = string.Format("<a href=\"{0}:{1}('{2}','{3}','{4}');\">{5}</a>", "javascript", "ftbs", splittedEmailAddress[0], splittedEmailAddress[1], Subject, (string.IsNullOrEmpty(DisplayValue) ? EmailAddress : DisplayValue)); } } else { result.Text = (string.IsNullOrEmpty(DisplayValue) ? EmailAddress : DisplayValue); } Controls.Add(result); Render(writer); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { if (!string.IsNullOrWhiteSpace(EmailAddress) && EmailAddress.EndsWith("TechnologyLiveConference.com", StringComparison.InvariantCultureIgnoreCase)) { yield return (new ValidationResult("Technology Live Conference staff should not use their conference email addresses.")); } }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var validationResults = new List <ValidationResult>(); if ((!String.IsNullOrEmpty(EmailAddress)) && EmailAddress.EndsWith("TechnologyLiveConference.com", StringComparison.OrdinalIgnoreCase)) { validationResults.Add(new ValidationResult("Technology Live Conference staff should not use their conference email addresses.")); } return(validationResults); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { List <ValidationResult> results = new List <ValidationResult>(); if (EmailAddress != null && EmailAddress.EndsWith("TechnologyLiveConference.com", StringComparison.InvariantCultureIgnoreCase)) { results.Add(new ValidationResult("Technology Live Conference staff should not use their conference email addresses.")); } return(results); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { List <ValidationResult> ValidationResult = new List <ValidationResult>(); if (!string.IsNullOrEmpty(EmailAddress) && EmailAddress.EndsWith("TechnologyLiveConference.com")) { ValidationResult.Add(new ValidationResult("Technology Live Conference staff should not use their conference email addresses.")); } return(ValidationResult); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var validationList = new List <ValidationResult>(); if (EmailAddress != null && EmailAddress.EndsWith(value: @"TechnologyLiveConference.com", comparisonType: StringComparison.OrdinalIgnoreCase)) { validationList.Add(new ValidationResult("Technology Live Conference staff should not use their conference email addresses.")); } return(validationList); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var result = new List <ValidationResult>(); var isTechConferenceMailAddress = EmailAddress?.EndsWith("TechnologyLiveConference.com", StringComparison.InvariantCultureIgnoreCase) ?? false; if (isTechConferenceMailAddress) { result.Add(new ValidationResult("Technology Live Conference staff should not use their conference email addresses.")); } return(result); }