【发布时间】:2014-10-26 03:37:00
【问题描述】:
我想要的是将输出的 IHtmlString 转换为字符串。
我有这个代码:
string text = @Html.Raw(Model.lastNoticias.Descricao);
此代码返回错误:
无法将 System.Web.IHtmlString 类型隐式转换为字符串。
完整代码:
@{
string text = @Html.Raw(Model.lastNoticias.Descricao);
}
@if (text.Length > 100)
{
@(text.Substring(0, 100) + "... ");
}
我该怎么做?
【问题讨论】:
-
string text = Model.lastNoticias.Descricao;? -
Model.lastNoticias.Descricao 是一个编码的 html。我需要解码它并在获取子字符串之后。
标签: c# html asp.net-mvc asp.net-mvc-4 razor