Copied to clipboard

Flag this post as spam?

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

  • Simon 47 posts 107 karma points
    Jun 04, 2019 @ 22:50

    Incorrect display/access RTE values of a Media object

    Created a new Media type today with a few Rich Text Editor fields. When attempting to access the values of these RTE fields, it either comes back blank or incorrect.

    Here is a trimmed down version of the razor code:

    @for (int index = 0; index < flexCtas1.Count(); index++) {
        CtaFlex flexCta = flexCtas1[index];

    Here's all the methods that either fail or come short of working correctly:

    Direct access: flexCta.CtaTextEnglish

    • Returns blank

    Property value access (strongly typed): flexCta.GetPropertyValue

    • Returns blank

    Property value access (no type): flexCta.GetPropertyValue("CtaTextEnglish")

    • Returns text including html tags but no conversion of internal links, urls, etc. e.g. i see this in the rendered version: href="/{localLink:28717}"

    What's the fix here? I have been developing with umbraco for several years and don't remember seeing this particular problem before.

    Using Umbraco version 7.4.3 assembly: 1.0.5948.18141

  • Chris Evans 106 posts 257 karma points c-trib
    Jun 05, 2019 @ 05:05
    Chris Evans

    Can I ask a few questions about your example:

    What is the flexCtas1 object in your code snippet above? e.g. is it an IEnumberable<CtaFlex>?

    How are you populating this flexCtas1 object?

    And is a CtaFlex a Models Builder class or a custom class you've written?

    It might also be useful to see your custom Media object definition (e.g. a screenshot of the media type in Settings)

  • Simon 47 posts 107 karma points
    Jun 05, 2019 @ 16:04

    CtaFlex is the Media type created in the backoffice (i.e. Models Builder).

    flexCtas1 is created as follows:

    List<CtaFlex> flexCtas1 = new List<CtaFlex>();
    string[] flexCtas1List = Model.Content.CaFlexCtasSection1.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
    if (flexCtas1List != null && flexCtas1List.Any()) {
        flexCtas1 = Umbraco.TypedMedia(flexCtas1List).OfType<CtaFlex>().ToList();

    The only field that concerns me right now is the one that uses the Rich Text Editor field (CtaTextEnglish)

Please Sign in or register to post replies

Write your reply to: