Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

CancelReason in MovingPage

Vote:
 

I want to controll the deletion of blocks and send a message to the user. So I setup the event Instance_MovingPage in EPiServer.DataFactory.Instance. In the event I set a message for the user in e.CancelReason and e.CancelAction = true. The move is canceled but my reason message is not displayed. There is a standard message displayed instead.

Isn´t this supposed to work?

/Raymond

#73083
Jul 05, 2013 10:34
Vote:
 

Hi Raymond,

Have you resolved the issue? Seems that I have faced the same..

#147721
Apr 22, 2016 9:05
Vote:
 

Works in EPiServer 9 at least...tried this:

  [ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
    public class EventsInitialization : IInitializableModule
    {
        private IContentEvents _contentEvents;
        public void Initialize(InitializationEngine context)
        {
            if (_contentEvents == null)
            {
                _contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
            }
            _contentEvents.MovingContent += Moving;

....

 private void Moving(object sender, ContentEventArgs e)
        {
            var args = e as MoveContentEventArgs;
            if (args != null)
            {
                args.CancelAction = true;
                args.CancelReason = "this didn't work out at all";
            }
        
            
        }

....

  public void Uninitialize(InitializationEngine context)
        {
            if (_contentEvents == null)
            {
                _contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
            }
            _contentEvents.MovingContent -= Moving;

...

Works like a charm! 

#147726
Edited, Apr 22, 2016 10:47
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.