More in this section
Forums / Developing with Sitefinity / ContentManager Executing Event not working in edit mode

ContentManager Executing Event not working in edit mode

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. gopalraman gopal
    gopalraman gopal avatar
    52 posts
    Registered:
    03 Dec 2009
    04 May 2011
    Link to this post
    Hi

    According to my functionality whenever "Generic Content"(Modules -> Generic Content -> Content Items) is created or updated, i need to find and replace a particular word in it. So that i created a ContentManager Executing Event in global.asax file as follows.

      void Application_Start(object sender, EventArgs e)
        {                

            Telerik.Cms.Engine.ContentManager.Executing += new EventHandler<Telerik.ExecutingEventArgs>(ContentManager_Executing);

        }

     void ContentManager_Executing(object sender, Telerik.ExecutingEventArgs e)
        {
            if (sender is Telerik.Cms.Engine.Data.Providers.DefaultProvider)
            {           
                if (e.CommandName == "CreateContent" || e.CommandName == "UpdateContent")
                {
                    Telerik.Cms.Engine.IContent libraryItem = e.CommandArguments as Telerik.Cms.Engine.IContent;
                    if (libraryItem != null)
                    {

                        libraryItem.Content = libraryItem.Content.ToString().Replace("xxxx", "yyyyyy");
                    }
                }
            }
    }

    After creating a new content in "view screen" the text get replaced, but when i am trying to edit it the old text which i created is appearing. How to overcome this issue.

    Thanks in advance.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    09 May 2011
    Link to this post
    Hi gopalraman,

    You should get the content item into a transaction

    Telerik.Cms.Engine.IContent c = manager.GetContent(((Telerik.Cms.Engine.Data.CmsContentBase)(e.CommandArguments)).ID);



    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered