Quantcast
Channel: Using Optimizely Platforms
Viewing all articles
Browse latest Browse all 8020

SavingContent event - update block content - values not updated

$
0
0

Hi!

I am updating content on a block in the SavingContent event.

    [InitializableModule]
    [ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
    public class BlockEventsInitialization : IInitializableModule
    {
        private IContentEvents _events;
        public void Initialize(InitializationEngine context)
        {
            _events = ServiceLocator.Current.GetInstance();
            _events.SavingContent += SavingContent;
        }
        private void SavingContent(object sender, ContentEventArgs e)
        {
            var block = e.Content as MyTestBlock;
            if (block != null)
            {
                block.Text = "New text";
                e.Content = block as IContent;
            }
        }
        public void Uninitialize(InitializationEngine context)
        {
            _events.SavingContent -= SavingContent;
        }
    }

In my case I am replacing blocks in a ContentArea, this is just a small example with the same result.

The Text property does not say "New text" until I reload the page, hitting "Ready to Publish", actually publish the block or go to another block/page and then go back the block I am updating.

I do not want to publish my changes, just save.

Anyone have an idea how to update values without reloading or publish the block?

/Magnus


Viewing all articles
Browse latest Browse all 8020

Trending Articles