Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I render MvcHtmlString as HTML

I'm getting MvcHtmlString as a model to my view. And I need to render this string as HTML. At the moment I tried to do:

@Model.ToHtmlString()

But it gives me plaint text on my page. I know it should be like really trivial answer. But I can't get it =)

like image 480
Naz Avatar asked Jan 15 '11 11:01

Naz


2 Answers

You need to use the Html.Raw helper:

@Html.Raw(Model.ToHtmlString())
like image 119
Oded Avatar answered Oct 21 '22 03:10

Oded


try to use

@(Model)

and implement in class the ToHtmlString() method

like image 22
Tomás Giacaman Avatar answered Oct 21 '22 03:10

Tomás Giacaman