More in this section

Forums / Developing with Sitefinity / Updating ContentBlock pulled from pageManager.LoadControl()

Updating ContentBlock pulled from pageManager.LoadControl()

1 posts, 0 answered
  1. Aaron
    Aaron avatar
    4 posts
    Registered:
    19 Jul 2012
    15 Aug 2012
    Link to this post
    Is there a way to save a modified ContentBlock that I extracted from the LoadControl method? Here's what I have so far, and it doesn't seem to work sadly.

    var pageManager = PageManager.GetManager();
     
     foreach (var c in duplicated.Page.Controls)
     {
         // go through the properties, use the ID to grab the right text
         foreach (var p in c.Properties)
         {
             if (p.Name == "ID")
             {
                 var content = pageContent.Where(content_pair => content_pair.Key == p.Value).SingleOrDefault();
                 var control = pageManager.LoadControl(c);
                 if (control is ContentBlock)
                 {
                     ContentBlock contentBlock = (ContentBlock) control;
                     contentBlock.Html = content.Value;
                 }
             }
         }
     }
     pageManager.SaveChanges();
1 posts, 0 answered