For one of my razor macros I want to have the option to allow some before and after text which can, if necessary be html. I have this working in XSLT by using disable-output-escaping however don't know how to get it working in razor.
This is part of my macro
string before = @Parameter.insertBefore;
if (!string.IsNullOrEmpty(before)) { @Html.Raw(before) }
When I use Html.Raw it outputs the <p> on the page, the html has been encoded. However if I don't use Html.Raw I get the text as it is sent to the parameter.
Passing html as macro parameters
For one of my razor macros I want to have the option to allow some before and after text which can, if necessary be html. I have this working in XSLT by using disable-output-escaping however don't know how to get it working in razor.
This is part of my macro
When I use Html.Raw it outputs the <p> on the page, the html has been encoded. However if I don't use Html.Raw I get the text as it is sent to the parameter.
Using Html.Raw
<p>
Not using Html.Raw
&lt;p&gt;
Does anyone know how to solve this.
If I understand you correctly, you could decode the input then output it raw:
Doh! I tried Html.Encode ;)
Thanks, that works.
This doesn't seem to be working now in 6.1.3 using MVC :(
This is the html output with the various encodings. Can anyone advise how to fix.
@Html.Raw(Server.HtmlDecode(Parameter.afterText)) = <p>
@Server.HtmlDecode(Parameter.afterText) = &lt;p&gt;
@Parameter.afterText = &amp;lt;p&amp;gt;
Hi Suzyb,
Please try @Html.Raw(HttpUtility.HtmlDecode(before)).
For me it's working in umbraco 6.2.1
is working on a reply...