Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bendik Engebretsen 105 posts 202 karma points
    Nov 11, 2016 @ 15:23
    Bendik Engebretsen
    0

    Backoffice notification message duration

    I'm working with backoffice events where I am showing some important messages to the user through the EventMessage(...) interface. However, I find that the messages don't stay for more than a few seconds, and since some of my messages are a bit "elaborated", I would like them to stay a little bit longer.

    Anybody who knows how to do that?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 14, 2016 @ 10:00
    Jan Skovgaard
    0

    Hi Bendik

    I'm afraid that I don't know how to do this using the C# API's but I'm wondering wether what you're doing could be achieved easier using the backoffice UI api and then making use of the notifications service here https://our.umbraco.org/apidocs/ui/#/api/umbraco.services.notificationsService - Then you could perhaps just set the "sticky" option to true if you're using the "add" method?

    Hope this helps.

    /Jan

  • Bendik Engebretsen 105 posts 202 karma points
    Nov 15, 2016 @ 12:57
    Bendik Engebretsen
    0

    Hi Jan and thank you for your advice!

    I am using the notificationService in my plugin controller, but here I am stuck down in this server-side event handler. And I don't know any way to pass information from here up to the controller. But maybe you can help? Here's my code:

    public class SaveContentEventHandler : ApplicationEventHandler
    {
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            ContentService.Saving += ContentServiceSaving;
        }
    
        private void ContentServiceSaving(IContentService sender, SaveEventArgs<IContent> e)
        {
            e.Messages.Add(new EventMessage("My message title", "My message", EventMessageType.Error));
        }
    }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft