Copied to clipboard

Flag this post as spam?

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


  • greengiant83 88 posts 109 karma points
    Jun 07, 2011 @ 06:30
    greengiant83
    0

    List child node's body text

    I have a text page with several text page's under them.  Each text page has a bodyText property that is a rich text editor.

    How can I list the body text from each of the children?

    This:

    <umbraco:Macro  runat="server" language="cshtml">
          @inherits umbraco.MacroEngines.DynamicNodeContext
          
          @foreach (var item in @Model.Children) 
          {
            <div>
              <h2>@item.Name</h2>
              @Html.Raw(item.BodyText)
            </div>
          }
        </umbraco:Macro>

    yeilds: Error loading Razor Script 

    The best overloaded method match for 'System.Web.WebPages.Html.HtmlHelper.Raw(string)' has some invalid arguments

    simply putting:

    @item.BodyText

    yields: umbraco.MacroEngines.DynamicXml

    How can I get the actual contents of the body text to render?

  • Alex 78 posts 136 karma points
    Jun 07, 2011 @ 08:21
    Alex
    0

    This is probably to do with the DynamicNode duck-typing your BodyText incorrectly because of some unhandled tag. Try this

    @Html.Raw(item.BodyText.ToXml().ToString())

    or

    @Html.Raw(item.GetProperty("bodyText").Value)
Please Sign in or register to post replies

Write your reply to:

Draft