How to use client validation in the Shape?

Topics: General
Apr 14, 2011 at 9:54 AM

Hi team,

I've created a shape that is get rendred throught the Driver like this:

protected override DriverResult Display(PrepareToTestStepPart part, string displayType, dynamic shapeHelper)
            return ContentShape("Parts_Enablements_PrepareToTestStep_View",
                () => shapeHelper.Parts_Enablements_PrepareToTestStep_View(
                    ContactInfo: part.TechnicalContactInfo,
                    HubName: contextAccessor.CurrentContext.CurrentEnablement.HubName,
                    TestingPrice: contextAccessor.CurrentContext.CurrentEnablement.TestingPlanPrices[PaymentPlanType.InHouseTesting]

I want to use DataAnnotations for validating form values that is placed on my Shape and I've used DataAnnotations for this:

    public class TechnicalContactInfo : IValidatableObject
        public TestingType TestingType { get; set; }

        //public string VendorOr3rdPary { get; set; }

        public string CompanyName { get; set; }

        [Required(ErrorMessage = "First Name is missing."), StringLength(30)]
        public string FirstName { get; set; }

        [Required(ErrorMessage = "Last Name is missing."), StringLength(30)]
        public string LastName { get; set; }

        [Required(ErrorMessage = "Phone is missing."), StringLength(20)]
        public string Phone { get; set; }

        public string Fax { get; set; }

        [Required(ErrorMessage = "Email is missing.")]
        [Email(ErrorMessage = "Email is not valid.")]
        public string Email { get; set; }

        public string Title { get; set; }

Sever-side validation works well, but client validation doesn't. Do you have any suggestions how to fix this? Thanks!

Apr 16, 2011 at 4:29 PM

Can you show us your EditorTemplate code; that's where client validation would need to be supported.