将带有换行符的字符串传递到cshtml页面 [英] passing a string with line break on to a cshtml page
本文介绍了将带有换行符的字符串传递到cshtml页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个如下的mypage.cshtml
I have a mypage.cshtml as below
<p><span>@r.get("My_Message")</span></p>
下面是我在resx文件中的条目
Below is my entry in my resx file
<data name="my_message" xml:space="preserve">
<value>This is first line <br/> This is my second line <br/></value>
</data>
当我运行mypage.cshtml时,上述字符串的换行符不起作用.请帮助
When i run mypage.cshtml , my line break char for the above string is not working . please help
我得到的输出是
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
推荐答案
尝试:
<p><span>@Html.Raw(HttpUtility.HtmlDecode(r.get("My_Message")))</span></p>
这篇关于将带有换行符的字符串传递到cshtml页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文