0

Im trying to enforce the user to set a DateTime for StopPublish

[Required]     
public virtual DateTime EnforceStopPublish
{ get; set; }

    public override DateTime? StopPublish
    {
        get { return EnforceStopPublish; }
    }

didn't work, is there another possible way, maybe by an Publishing event? example.

thanks in advance

Gonzalo
  • 322
  • 1
  • 3
  • 13

2 Answers2

1

Never tried it on the StopPublish property (not sure about any side-effects), but could you do it with standard data annotations, i.e. a Requiredattribute on your overriding property?

Ted Nyberg
  • 7,001
  • 7
  • 41
  • 72
0

You could also do it in the SetDefaultValues method. The user will then of course be able to remove or change the stoppublishdate, but that can certanly be ok in a lot of cases.

public override void SetDefaultValues(ContentType contentType)
{
    base.SetDefaultValues(contentType);
    this[MetaDataProperties.PageStopPublish] = DateTime.Now.AddDays(5);
}
andreasnico
  • 1,478
  • 14
  • 23