Copied to clipboard

Flag this post as spam?

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


  • Anthony Candaele 1197 posts 2049 karma points
    Feb 03, 2012 @ 15:49
    Anthony Candaele
    0

    Programmaticaly create document node

    Hi,

    This is the first time I need to programmaticaly create a document node from a user control (.ascx). As this is the first time I'm doing this, I'm looking for some good demo code or documentation.

    Does anyone know where I can find this?

    Thanks for your help,

    Anthony

  • Mike Chambers 621 posts 1203 karma points c-trib
    Feb 03, 2012 @ 15:57
  • Anthony Candaele 1197 posts 2049 karma points
    Feb 03, 2012 @ 16:13
    Anthony Candaele
    0

    Hi Mike,

    Thanks for the link. I already stumbled upon this page and it contains some basic information, but I was looking for some more worked out example code. 

    Like for instance how does one set properties of a document node etc...

    Thanks for your help,

    Anthony

  • Pasang Tamang 252 posts 394 karma points
    Feb 03, 2012 @ 16:21
    Pasang Tamang
    3

    Hi Anthony,

    You can set the value of the property of newly created document like this way

    Document doc = Document.MakeNew("My new document", dt, author, 1018); 
    doc.getproperty("propertyAlias").value = "propertyValue";
    doc.Save();

    Hope this helps you

    PTamang

  • bob baty-barr 1180 posts 1294 karma points MVP
    Feb 03, 2012 @ 16:27
    bob baty-barr
    1

    @anthony,

    once you create the document

    Document newDoc = Document.MakeNew(pageName, DocumentType.GetByAlias("aliasName"), umbraco.BusinessLogic.User.GetCurrent(), nodeIDUnder);

    then you just get the property by id and set the value...

    newDoc.getProperty("docProperty").Value = what you want it to be;
  • bob baty-barr 1180 posts 1294 karma points MVP
    Feb 03, 2012 @ 16:28
    bob baty-barr
    1

    haha, i was too late!

  • Anthony Candaele 1197 posts 2049 karma points
    Feb 03, 2012 @ 19:17
    Anthony Candaele
    0

    @Ptamang and bob baty-barr thanks for this info guys, I'll give it a try.

    greetings,

    Anthony

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Feb 03, 2012 @ 20:59
    Jan Skovgaard
    1

    Hi Anthony

    I'd just like to add that you probably can find (if you have not already seen it) some usefull information about using the API to create document types etc. in this WIKI entry: http://our.umbraco.org/wiki/reference/api-cheatsheet 

    Happy coding :)

    /Jan

  • Anthony Candaele 1197 posts 2049 karma points
    Feb 04, 2012 @ 08:26
    Anthony Candaele
    0

    Hi Jan,

    This is exactly what I need :) 

    Thanks a lot,

    Anthony

  • 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