Copied to clipboard

Flag this post as spam?

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


  • Yuval Lombard 14 posts 44 karma points
    Dec 01, 2013 @ 09:51
    Yuval Lombard
    0

    Creating a Document/Node in Web Forms User Controls Umbraco 6.1.6 API

    Hi guys!

    I'm having troubles creating a Document/Node via Umbraco 6.1.6 API I'm currently using User Controls in a Web Forms project, and this is the code im using:

    DocumentType dt = DocumentType.GetByAlias("uBlogsyComment");

    User author = User.GetUser(0);

    Document doc = Document.MakeNew("My new document", dt, author,

    if(toPublish) doc.Publish(author);

    Would love to get some help with it

    tnx!

  • julius 107 posts 289 karma points
    Dec 01, 2013 @ 13:34
    julius
    0

    I am using the content service to create new documents. Hope this helps you:

    var contentService = ApplicationContext.Current.Services.ContentService;
    var newDoc = contentService.CreateContent("YourNewNodeName", yourParentDocument, "YourContentType");
    newDoc.setValue("yourField1", "yourValue1");
    newDoc.setValue("yourField2", "yourValue2");
    contentService.SaveAndPublish(newDoc);

    Read more here: http://umbraco.com/follow-us/blog-archive/2013/1/22/introducing-contentservice-aka-the-v6-api.aspx/

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies