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

Forums / Developing with Sitefinity / Change Generic Content programatically

Change Generic Content programatically

3 posts, 1 answered
  1. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    02 Nov 2010
    Link to this post
    I am trying to programatically change the value of a generic content item. My current code modifies the current version but I would like to create a new version. How can I do this?

    var content = manager.GetCurrentState(contentToUpdate.ID);
    content.Content = "x";

    manager.SaveContent(content);


    Thanks,

    Chris.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Nov 2010
    Link to this post
    Hello Chris,

    You have to use the staged version of the content item. If you save staged version, we create a new VersionItem for this object.

    var manager = new ContentManager("News");
    var cnt = manager.GetStagedContent(new Guid("dccbc232-e32f-45d8-b765-b62e4ab6ff51"));
    cnt.Content = "hello world";
    manager.SaveContent(cnt);


    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  3. Chris
    Chris avatar
    87 posts
    Registered:
    11 May 2010
    02 Nov 2010
    Link to this post
    Perfect, thanks Ivan.
Register for webinar
3 posts, 1 answered