Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am using umbraco v 4.7.0.RC (Assembly version: 1.0.4077.25828) but when I use @item.bodyText in a Razor Macro, I get back the umbraco.MacroEngines.DynamicXml, not the HTML. How to fix this?
What is "item" supposed to be? A full code sample would be helpful.
When you're just trying to display the bodyText of the current page you would do something like this:
<div class="article"> @Html.Raw(Model.bodyText) </div>
Doing Html.Raw here so that you don't just get the html encoded version, but the full html output.
Oh, I tried that, but I get this error:
The best overloaded method match for 'System.Web.WebPages.Html.HtmlHelper.Raw(string)' has some invalid arguments
Not sure what's up with that... Here's my complete macro:
<umbraco:Macro runat="server" language="cshtml">@inherits umbraco.MacroEngines.DynamicNodeContext@{ var numberOfItems = 10; }<div class="donors-tab-container">@foreach (var item in @Model.Children) { <div id="@item.Id" class="tab-content"> <p>@Html.Raw(item.bodyText)</p> </div>}</div></umbraco:Macro>
Got it working with this syntax:
@Html.Raw(item.GetProperty("bodyText").ToString())
Your example code works just fine but you need to make sure to pass an empty string to Html.Raw if the bodyText is empty:
<div class="donors-tab-container"> @foreach (var item in @Model.Children) { <div id="@item.Id" class="tab-content"> <p>@Html.Raw(item.bodyText.ToString())</p> </div> } </div>
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Returning HTML from RichText Editor?
I am using umbraco v 4.7.0.RC (Assembly version: 1.0.4077.25828) but when I use @item.bodyText in a Razor Macro, I get back the umbraco.MacroEngines.DynamicXml, not the HTML. How to fix this?
What is "item" supposed to be? A full code sample would be helpful.
When you're just trying to display the bodyText of the current page you would do something like this:
Doing Html.Raw here so that you don't just get the html encoded version, but the full html output.
Oh, I tried that, but I get this error:
The best overloaded method match for 'System.Web.WebPages.Html.HtmlHelper.Raw(string)' has some invalid arguments
Not sure what's up with that... Here's my complete macro:
<umbraco:Macro runat="server" language="cshtml">
@inherits umbraco.MacroEngines.DynamicNodeContext
@{ var numberOfItems = 10; }
<div class="donors-tab-container">
@foreach (var item in @Model.Children) {
<div id="@item.Id" class="tab-content">
<p>@Html.Raw(item.bodyText)</p>
</div>
}
</div>
</umbraco:Macro>
Got it working with this syntax:
@Html.Raw(item.GetProperty("bodyText").ToString())
Your example code works just fine but you need to make sure to pass an empty string to Html.Raw if the bodyText is empty:
is working on a reply...