在Razor WebGrid中显示HTML内容

时间:2014-06-04 10:39:44

标签: c# html razor

我正在尝试使用webgrid以HTML格式显示显示内容。我该怎么做呢?

屏幕截图:

enter image description here

我的网格:

@grid.GetHtml(htmlAttributes: new { id = "grid" }, fillEmptyRows: false, tableStyle: "table", footerStyle: "foot", mode: WebGridPagerModes.All, firstText: "<< First", previousText: "< Prev", nextText: "Next >", lastText: "Last >>", columns: new[] {
grid.Column("PublishedContent",
                header: "Content"
    ),
            grid.Column("Layout", header: "Layout"),
            grid.Column("_Status", header: "Status"),

    grid.Column("",
                header: "Actions", style: "_action",
                format: @<text>
                    @Html.ActionLink("Edit", "Published", new { id = item.id }, new { @class = "editDialog"/*, data_dialog_id = "edit-Dialog"*/ })
                    |
                    @Html.ActionLink("Delete", "_DeletePublished", new { id = item.id }, new { @class = "confirmDialog" })
                </text>
    )
    })

1 个答案:

答案 0 :(得分:0)

您需要在Html.Raw()参数中使用format来阻止HtmlEncoding发生:

grid.Column("PublishedContent", header: "Content", format: @<text>@Html.Raw(item.PublishedContent)</text>)