5

My models:

    public class htmlDump {
        public string html { get; set; }
    }

    public string getSquares() {
        var sq = (from s in n.squares
                  where s.active == true
                 orderby s.date_created descending
                 select s.html).First();
        return sq;
    }

My controller:

    public ActionResult index() {
        intranetGS.htmlDump sq = new intranetGS.htmlDump {
            html = g.getSquares()
        };

        return View(sq);
    }

My View:

 @Html.DisplayFor(model => model.html)

All I want is for the html being passed to the view to be rendered as html and not as text. Surely there's something different I can use in the view (instead of .DisplayFor) that will work. Any suggestions?

Thanks very much!

shubniggurath
  • 956
  • 1
  • 15
  • 31

1 Answers1

10
@Html.Raw(Model.html)

NOTE: if this data can be input by the user - make sure it's sanitized.

Mike Perrenoud
  • 66,820
  • 29
  • 157
  • 232