shu*_*ath 5 c# asp.net-mvc linq-to-sql razor
我的模特:
    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;
    }
我的控制器:
    public ActionResult index() {
        intranetGS.htmlDump sq = new intranetGS.htmlDump {
            html = g.getSquares()
        };
        return View(sq);
    }
我的看法:
 @Html.DisplayFor(model => model.html)
我想要的只是传递给视图的html呈现为html而不是文本.当然,我可以在视图中使用不同的东西(而不是.DisplayFor).有什么建议?
非常感谢!
Mik*_*oud 10
@Html.Raw(Model.html)
注意:如果用户可以输入此数据- 请确保已对其进行消毒.
| 归档时间: | 
 | 
| 查看次数: | 5088 次 | 
| 最近记录: |