Tony
Tony

Reputation: 12695

MVC 3 Insert string HTML code using jquery

the preview variable contains the HTML code. I want to display that code rendered, but is is being rendered as a raw text, why ?

 $("#pdf-dialog").dialog("option" , 'open' , function() { 
     @if (!string.IsNullOrEmpty(preview))
     {
         <text>
             $("#pdf-dialog").html("@preview");
         </text>
     }
 });

Upvotes: 0

Views: 106

Answers (1)

Claudio Redi
Claudio Redi

Reputation: 68400

Try with HtmlHelper.Raw

@Html.Raw(preview)

Upvotes: 2

Related Questions