Copied to clipboard

Flag this post as spam?

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


  • Don Langham 1 post 71 karma points
    Dec 12, 2015 @ 22:26
    Don Langham
    0

    Saving HTML markup with content created with content service

    I have a proof-of-concept application that calls the ContentService to save documents to my Umbraco site.

    The document type has a single custom generic property of type rich text editor.

    Using my code that calls the ContentService, I can create a document and save it, but any html markup included in the content is stripped when saved.

    I've Googled this pretty hard, and while I've found others with the same question/problem, I've not found any answers.

    Can I save html markup with my content? How?

    For reference, here's the code snippet used in my proof of concept:

            public void Publish(string Content, string title)
        {
    
            var cs = ApplicationContext.Current.Services.ContentService;
            var page = cs.CreateContent(title, 1050, "RegularContent", 0);
    
            page.SetValue("pageText", Content);
            cs.SaveAndPublishWithStatus(page);
    
        }
    
  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Dec 14, 2015 @ 07:43
    Dave Woestenborghs
    0

    I think you need to change your content to be of the type IHtmlString and then it will work.

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft