+1-888-365-2779
Try Now
More in this section

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

ContentManager Executing Event not working in edit mode

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:
    25 Nov 2016
    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