How to transform a string into HTML C #

4

I'm using a component and need to load it with HTML snippet that comes in a variable. For that I created this JQuery:

$(document).ready(function(){
    $('.mentions-kinder').html('@HttpUtility.HtmlDecode(Model.FormulaRecover)');
});

But even so when it squeezes, it does not load the code, and it looks like this:

  

If JQuery read the same code as the above print it worked, but the code when I inspect the page looks like this:

$(document).ready(function(){
    $('.mentions-kinder').html('<span class="mention badge badge-warning" contenteditable="false" serialized-mention="[#Quantidade de Visitas](tag:12)"><span class="tag-trigger">Parametro: </span><span class="tag-value">Quantidade de Visitas</span><span class="delete-mention tag-delete"><i class="icon-remove"></i></span></span> <span class="mention badge badge-primary" contenteditable="false" serialized-mention="(area:104)"><span class="area-trigger">Area: </span><span class="area-value">Alessandro Spricigo</span><span class="delete-mention area-delete"><i class="icon-remove"></i></span></span> *');
});

And it all goes wrong. Any ideas for that?

    
asked by anonymous 18.03.2017 / 23:26

1 answer

5

When you have string of html it is not rendered in DOM , so this string can be rendered it is necessary to call the Html.Raw() method passing string html . The Html.Raw() method Transforms string into a html tag.

Solution

In your case you should use as below:

@Html.Raw(HttpUtility.HtmlDecode(Model.FormulaRecover))
    
19.03.2017 / 00:13