Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

PageType Before and End date validation

Vote:
 

Hi,

I am looking at adding validation to a Start Date and End Date - where the user can not enter an End Date before the Start Date. The code is in the pageType and will be used in the CMS for a page set up.

Is there any way that this can be done?

Thanks

Jon

#81729
Feb 25, 2014 9:25
Vote:
 

Have you tried to write your own validation class that implements IValidate interface?

http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-CMS/75/Validation/Validation/

#81742
Feb 25, 2014 11:57
Vote:
 

You could also use an InitializableModule to hook into the saving event:

// inside Initialize 
ServiceLocator.Current.GetInstance<IContentEvents>().SavingContent += DisplayModesInitialization_SavingContent;


void DisplayModesInitialization_SavingContent(object sender, ContentEventArgs e)
   {
       if (DatesNotValid(e.Content))
         {
              e.CancelAction = true;
              e.CancelReason = "Your error message";
         }
   }

    

 

#81744
Feb 25, 2014 12:39
Vote:
 

This does not seem to work in neither 7.12.1 nor 7.14.1 (I tried upgrading since it did not work in 7.12.1).

I receive the following:

After which the whole UI gets slow and hardly works. Bug?

#91651
Edited, Oct 10, 2014 9:03
Vote:
 

Image upload does not seem to work either. :)
Here's a link: http://uploadpie.com/td2bX

#91652
Edited, Oct 10, 2014 9:04
Vote:
 

I wrote a blog post a while back about using the IValidator interface that may be of use: http://www.david-tec.com/2012/06/EPiServer-7-Preview---IValidator-interface/

#91658
Oct 10, 2014 11:13
Vote:
 

Thank you David! It's really a clean approach! :)

#91660
Oct 10, 2014 11:30
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.