Copied to clipboard

Flag this post as spam?

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


  • Alexandre Demers 3 posts 73 karma points
    Jun 07, 2017 @ 19:31
    Alexandre Demers
    0

    Adding propreties after creating a page programatically

    Hi,

    I'm having trouble programatically adding propreties to my page. Whenever I visit the page I added, Visual Studio gives me a RuntimeBinderException : 'string' does not contain a definition for 'sections'.

    Here's the code I'm using

    //create a new page
            var newPage = ApplicationContext.Current.Services.ContentService.CreateContentWithIdentity(name, parentId, "myDocType");
            //put the body text in it
            newPage.SetValue("content", text);
            var status = ApplicationContext.Current.Services.ContentService.SaveAndPublishWithStatus(newPage);
            return String.Format("Page creation {0}!", status);
    

    I'm using a custom Document type that has a single Textbox in it.

    The program always crashes in the Fanoe.cshtml file. I realised that my Model object is weird, because it only contains the text I entered and nothing else.

    Does anyone knows how I am supposed to fill the propreties of my page?

    EDIT : I've found the problem : It was because I forgot to select a template for my DocumentType

Please Sign in or register to post replies

Write your reply to:

Draft