1

I am creating a inputs via repeater and after submit, validation error shows in Console, but error message does not shows in

Repeater:

                            <div class="form-group">
                                <label>
                                    <dot:Literal Text="{value: Common.Phone}" />
                                </label>
                                <div class="phone input-group">
                                    <div class="phone__predvolba">
                                        <bp:DropDownList DataSource="{value: _parent.PhoneCodes}"
                                                         SelectedValue="{value: PhoneCode }"
                                                         Validation.Enabled="false"
                                                         class="admin-control admin-dropdown" />
                                    </div>
                                    <div class="phone__cislo">
                                        <dot:TextBox Text="{value: PhoneNumber}" Type="Telephone" class="admin-control" />
                                    </div>
                                </div>
                            </div>

                            <div class="position-relative text-danger">
                                <dot:Validator Value="{value:  PhoneNumber}"
                                               ShowErrorMessageText="true" />
                            </div>

                        </ItemTemplate>

DTO:

public class EmailBaseDTO : IEntity<int>, IValidatableObject
{
    public int Id { get; set; }

    [Required(ErrorMessageResourceName = nameof(Common.Resources.Admin.Common.Email_RequiredValidation),
        ErrorMessageResourceType = typeof(Common.Resources.Admin.Common))]
    [StringLength(250,
        ErrorMessageResourceName = nameof(eCENTRE.Common.Resources.Admin.Common.String_Length_Validation_50),
        ErrorMessageResourceType = typeof(eCENTRE.Common.Resources.Admin.Common))]
    public string Value { get; set; }

    public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
    {
        if (!String.IsNullOrEmpty(Value) && !StaticFunctions.IsValidEmail(Value))
        {
            yield return new ValidationResult(
                UserTexts.EmailValidation,
                new[] { nameof(Value) }
            );
        }
    }
}

This DTO is used in my DetailDTO like this

public ICollection<EmailBaseDTO> Emails { get; set; } = new List<EmailBaseDTO>();

On image, you can see that validation error is correctly triggered and submit is interupted.

enter image description here

Daniel Rusnok
  • 449
  • 1
  • 7
  • 14
  • The method in DTO class returns the `ValidationResult` for the `Value` property, but the `Validator` in the page references the `PhoneNumber` property. – Tomáš Herceg Oct 07 '17 at 11:40

0 Answers0