【问题标题】:ASP.MVC Html helper to format textASP.MVC Html 帮助器格式化文本
【发布时间】:2018-04-01 20:03:47
【问题描述】:

我的字符串是:

 string title = "CaSiO<sub>3</sub> perovskite in diamond indicates the recycling of oceanic crust into the lower mantle."

我使用了@Html.Raw(title) 并得到了

CaSiO<sub>3</sub> perovskite in diamond indicates the recycling of oceanic crust into the lower mantle.

如何在视图中打印它:

金刚石中的CaSiO3钙钛矿表明洋壳循环进入下地幔。

【问题讨论】:

    标签: asp.net-mvc razor html-helper


    【解决方案1】:

    @Html.Raw(WebUtility.HtmlDecode(title)) 将以您想要的格式显示字符串。

    (但是为什么首先要以这种方式定义字符串?为什么不用&lt;sub&gt;&lt;/sub&gt; 定义它,然后只使用@Html.Raw() 呢?)

    【讨论】:

    • 谢谢。有用。我正在使用 PubMed API,不幸的是他们就是这样格式化一些数据的。
    猜你喜欢
    • 1970-01-01
    • 2011-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-24
    相关资源
    最近更新 更多