passing a string with line break on to a cshtml page

假装没事ソ 提交于 2020-01-04 09:09:11

问题


I have a mypage.cshtml as below

<p><span>@r.get("My_Message")</span></p>

Below is my entry in my resx file

<data name="my_message" xml:space="preserve">
<value>This is first line &lt;br/&gt; This is my second line &lt;br/&gt;</value>
</data>

When i run mypage.cshtml , my line break char for the above string is not working . please help

The output I am getting is

This is first line <br/> This is my second line <br/>

I don't know why lines are not breaking I need an output as below

This is first line
This is my second line

回答1:


Try:

<p><span>@Html.Raw(HttpUtility.HtmlDecode(r.get("My_Message")))</span></p>


来源:https://stackoverflow.com/questions/8046210/passing-a-string-with-line-break-on-to-a-cshtml-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!