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
Hi,
I have a Macro-Parameter where the user can insert Code-Snippets in the grid. Simple example:
<script>alert("Hello World")</script>
I tried to render this Snipet in Razor, but it is rendered with html-Escape-code:
@inherits Umbraco.Web.Macros.PartialViewMacroPage @{ @Html.Raw(Model.MacroParameters["Code"]) }
Result:
<script> alert("hello world"); </script>
Is there a way to render it, so that the code does its job?
Comment author was deleted
Hmm Html.Raw should do the trick, the encoding probably happens in an earlier stage, will have to check
Which Umbraco version are you running?
Using 7.4 passing the code by macro Parameter Editor textarea.
Thank you for the hint to the "earlier stage".
This code does the job:
@Html.Raw(HttpUtility.HtmlDecode(Model.MacroParameters["Code"].ToString()))
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Render javascript-Code from String in Razor
Hi,
I have a Macro-Parameter where the user can insert Code-Snippets in the grid. Simple example:
I tried to render this Snipet in Razor, but it is rendered with html-Escape-code:
Result:
Is there a way to render it, so that the code does its job?
Comment author was deleted
Hmm Html.Raw should do the trick, the encoding probably happens in an earlier stage, will have to check
Which Umbraco version are you running?
Using 7.4 passing the code by macro Parameter Editor textarea.
Thank you for the hint to the "earlier stage".
This code does the job:
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.